Use @peertube/peertube-types

This commit is contained in:
Chocobozzz 2022-12-20 15:18:43 +01:00
parent 8ed5c72945
commit 1fe5ef9ef5
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
21 changed files with 5006 additions and 67 deletions

View File

@ -13,6 +13,7 @@
"dependencies": {},
"devDependencies": {
"@babel/types": "^7.20.5",
"@peertube/peertube-types": "^5.0.0",
"@popperjs/core": "^2.11.6",
"@sipec/vue3-tags-input": "^3.0.4",
"@types/axios": "^0.14.0",

View File

@ -1,7 +1,5 @@
import axios from 'axios'
import { ResultList, VideoPlaylistsSearchQuery } from '../../../PeerTube/shared/models'
import { VideoChannelsSearchQuery } from '../../../PeerTube/shared/models/search/video-channels-search-query.model'
import { VideosSearchQuery } from '../../../PeerTube/shared/models/search/videos-search-query.model'
import { ResultList, VideoChannelsSearchQuery, VideoPlaylistsSearchQuery, VideosSearchQuery } from '@peertube/peertube-types'
import { EnhancedVideoChannel } from '../../../server/types/channel.model'
import { EnhancedPlaylist } from '../../../server/types/playlist.model'
import { EnhancedVideo } from '../../../server/types/video.model'

View File

@ -78,7 +78,7 @@
import Pagination from '../components/Pagination.vue'
import SearchInput from '../components/SearchInput.vue'
import SortButton from '../components/SortButton.vue'
import { VideoChannelsSearchQuery, ResultList, VideosSearchQuery } from '../../../PeerTube/shared/models'
import { VideoChannelsSearchQuery, ResultList, VideosSearchQuery } from '@peertube/peertube-types'
import Nprogress from 'nprogress'
import { EnhancedPlaylist } from '../../../server/types/playlist.model'
import { PlaylistsSearchQuery } from '../../../server/types/search-query/playlist-search.model'

View File

@ -14,7 +14,6 @@
"skipLibCheck": true,
"lib": ["esnext", "dom"],
"paths": {
"@shared/*": [ "../PeerTube/shared/*" ],
"@/*": [
"./src/*"
]

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@
"source-map-support": "^0.5.21"
},
"devDependencies": {
"@peertube/peertube-types": "^5.0.0",
"@types/async": "^3.2.13",
"@types/body-parser": "^1.19.2",
"@types/config": "^3.3.0",

View File

@ -1,5 +1,5 @@
import express from 'express'
import { ResultList } from '../../PeerTube/shared/models/common/result-list.model'
import { ResultList } from '@peertube/peertube-types'
function badRequest (req: express.Request, res: express.Response) {
return res.type('json').status(400).end()

View File

@ -1,4 +1,4 @@
import { ResultList } from '../../../PeerTube/shared/models'
import { ResultList } from '@peertube/peertube-types'
import { CONFIG } from '../../initializers/constants'
import { CommonSearch } from '../../types/search-query/common-search.model'

View File

@ -373,7 +373,7 @@ function buildVideosMapping () {
}
function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo | DBVideoDetails {
return {
const video = {
id: v.id,
uuid: v.uuid,
shortUUID: v.shortUUID,
@ -402,13 +402,21 @@ function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo |
},
name: v.name,
truncatedDescription: v.truncatedDescription,
description: v.description,
waitTranscoding: v.waitTranscoding,
duration: v.duration,
thumbnailPath: v.thumbnailPath,
previewPath: v.previewPath,
embedPath: v.embedPath,
views: v.views,
viewers: v.viewers,
likes: v.likes,
dislikes: v.dislikes,
@ -418,11 +426,30 @@ function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo |
host: v.host,
url: v.url,
files: v.files,
streamingPlaylists: v.streamingPlaylists,
tags: (v as IndexableVideoDetails).tags ? (v as IndexableVideoDetails).tags : undefined,
account: formatActorForDB(v.account),
channel: formatActorForDB(v.channel)
}
if (isVideoDetails(v)) {
return {
...video,
trackerUrls: v.trackerUrls,
descriptionPath: v.descriptionPath,
support: v.support,
commentsEnabled: v.commentsEnabled,
downloadEnabled: v.downloadEnabled,
}
}
return video
}
function formatVideoForAPI (v: DBVideoDetails, fromHost?: string): EnhancedVideo {
@ -457,6 +484,7 @@ function formatVideoForAPI (v: DBVideoDetails, fromHost?: string): EnhancedVideo
name: v.name,
description: v.description,
truncatedDescription: v.truncatedDescription,
duration: v.duration,
tags: v.tags,
@ -475,6 +503,7 @@ function formatVideoForAPI (v: DBVideoDetails, fromHost?: string): EnhancedVideo
isLocal: fromHost && fromHost === v.host,
views: v.views,
viewers: v.viewers,
likes: v.likes,
dislikes: v.dislikes,
@ -492,3 +521,9 @@ export {
formatVideoForAPI,
buildVideosMapping
}
// ---------------------------------------------------------------------------
function isVideoDetails (video: IndexableVideo | IndexableVideoDetails): video is IndexableVideoDetails {
return (video as IndexableVideoDetails).commentsEnabled !== undefined
}

View File

@ -1,5 +1,5 @@
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
import { AccountSummary, VideoChannelSummary } from '../../../../PeerTube/shared/models'
import { AccountSummary, VideoChannelSummary } from '@peertube/peertube-types'
import { AdditionalActorAttributes } from '../../../types/actor.model'
import { formatActorImageForDB } from './'
import { buildActorImageMapping, formatActorImageForAPI, formatActorImagesForAPI, formatActorImagesForDB } from './elastic-search-avatar'

View File

@ -1,5 +1,5 @@
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
import { ActorImage } from '../../../../PeerTube/shared/models'
import { ActorImage } from '@peertube/peertube-types'
import { buildUrl } from '../../../helpers/utils'
function formatActorImageForAPI (image?: ActorImage) {

View File

@ -1,5 +1,5 @@
import { IndexablePlaylist } from 'server/types/playlist.model'
import { ResultList, Video, VideoChannel, VideoDetails, VideoPlaylist } from '@shared/models'
import { ResultList, Video, VideoChannel, VideoDetails, VideoPlaylist } from '@peertube/peertube-types'
import { doRequestWithRetries } from '../../helpers/requests'
import { INDEXER_COUNT, REQUESTS } from '../../initializers/constants'
import { IndexableChannel } from '../../types/channel.model'

View File

@ -1,4 +1,4 @@
import { ActorImage } from '../../PeerTube/shared/models'
import { ActorImage } from '@peertube/peertube-types'
export type AdditionalActorAttributes = {
handle: string

View File

@ -1,4 +1,4 @@
import { Account, VideoChannel, VideoChannelSummary } from '../../PeerTube/shared/models'
import { Account, VideoChannel, VideoChannelSummary } from '@peertube/peertube-types'
import { ActorImageExtended, AdditionalActorAttributes } from './actor.model'
import { IndexableDoc } from './indexable-doc.model'

View File

@ -1,4 +1,4 @@
import { AccountSummary, VideoChannelSummary, VideoPlaylist } from '../../PeerTube/shared/models'
import { AccountSummary, VideoChannelSummary, VideoPlaylist } from '@peertube/peertube-types'
import { AdditionalActorAttributes } from './actor.model'
import { IndexableDoc } from './indexable-doc.model'

View File

@ -1,6 +1,4 @@
import {
VideoChannelsSearchQuery as PeerTubeChannelsSearchQuery
} from '../../../PeerTube/shared/models/search/video-channels-search-query.model'
import { VideoChannelsSearchQuery as PeerTubeChannelsSearchQuery } from '@peertube/peertube-types'
import { CommonSearch } from './common-search.model'
export type ChannelsSearchQuery = PeerTubeChannelsSearchQuery & CommonSearch

View File

@ -1,4 +1,4 @@
import { VideoPlaylistsSearchQuery as PeerTubePlaylistsSearchQuery } from '../../../PeerTube/shared/models'
import { VideoPlaylistsSearchQuery as PeerTubePlaylistsSearchQuery } from '@peertube/peertube-types'
import { CommonSearch } from './common-search.model'
export type PlaylistsSearchQuery = PeerTubePlaylistsSearchQuery & CommonSearch

View File

@ -1,4 +1,4 @@
import { VideosSearchQuery as PeerTubeVideosSearchQuery } from '../../../PeerTube/shared/models/search/videos-search-query.model'
import { VideosSearchQuery as PeerTubeVideosSearchQuery } from '@peertube/peertube-types'
import { CommonSearch } from './common-search.model'
export type VideosSearchQuery = Omit<PeerTubeVideosSearchQuery, 'skipCount' | 'filter'> & CommonSearch & { boostLanguages: string[] }

View File

@ -1,5 +1,4 @@
import { Account, AccountSummary, Video, VideoChannel, VideoChannelSummary, VideoDetails } from '../../PeerTube/shared/models'
import { Account, AccountSummary, Video, VideoChannel, VideoChannelSummary, VideoDetails } from '@peertube/peertube-types'
import { AdditionalActorAttributes } from './actor.model'
import { IndexableDoc } from './indexable-doc.model'

View File

@ -17,10 +17,7 @@
"types": [
"node"
],
"baseUrl": ".",
"paths": {
"@shared/*": [ "PeerTube/shared/*" ]
}
"baseUrl": "."
},
"exclude": [
"node_modules",

2170
yarn.lock

File diff suppressed because it is too large Load Diff