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": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"@babel/types": "^7.20.5", "@babel/types": "^7.20.5",
"@peertube/peertube-types": "^5.0.0",
"@popperjs/core": "^2.11.6", "@popperjs/core": "^2.11.6",
"@sipec/vue3-tags-input": "^3.0.4", "@sipec/vue3-tags-input": "^3.0.4",
"@types/axios": "^0.14.0", "@types/axios": "^0.14.0",

View File

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

View File

@ -78,7 +78,7 @@
import Pagination from '../components/Pagination.vue' import Pagination from '../components/Pagination.vue'
import SearchInput from '../components/SearchInput.vue' import SearchInput from '../components/SearchInput.vue'
import SortButton from '../components/SortButton.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 Nprogress from 'nprogress'
import { EnhancedPlaylist } from '../../../server/types/playlist.model' import { EnhancedPlaylist } from '../../../server/types/playlist.model'
import { PlaylistsSearchQuery } from '../../../server/types/search-query/playlist-search.model' import { PlaylistsSearchQuery } from '../../../server/types/search-query/playlist-search.model'

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,5 +1,5 @@
import express from 'express' 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) { function badRequest (req: express.Request, res: express.Response) {
return res.type('json').status(400).end() 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 { CONFIG } from '../../initializers/constants'
import { CommonSearch } from '../../types/search-query/common-search.model' import { CommonSearch } from '../../types/search-query/common-search.model'

View File

@ -373,7 +373,7 @@ function buildVideosMapping () {
} }
function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo | DBVideoDetails { function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo | DBVideoDetails {
return { const video = {
id: v.id, id: v.id,
uuid: v.uuid, uuid: v.uuid,
shortUUID: v.shortUUID, shortUUID: v.shortUUID,
@ -402,13 +402,21 @@ function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo |
}, },
name: v.name, name: v.name,
truncatedDescription: v.truncatedDescription,
description: v.description, description: v.description,
waitTranscoding: v.waitTranscoding,
duration: v.duration, duration: v.duration,
thumbnailPath: v.thumbnailPath, thumbnailPath: v.thumbnailPath,
previewPath: v.previewPath, previewPath: v.previewPath,
embedPath: v.embedPath, embedPath: v.embedPath,
views: v.views, views: v.views,
viewers: v.viewers,
likes: v.likes, likes: v.likes,
dislikes: v.dislikes, dislikes: v.dislikes,
@ -418,11 +426,30 @@ function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo |
host: v.host, host: v.host,
url: v.url, url: v.url,
files: v.files,
streamingPlaylists: v.streamingPlaylists,
tags: (v as IndexableVideoDetails).tags ? (v as IndexableVideoDetails).tags : undefined, tags: (v as IndexableVideoDetails).tags ? (v as IndexableVideoDetails).tags : undefined,
account: formatActorForDB(v.account), account: formatActorForDB(v.account),
channel: formatActorForDB(v.channel) 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 { function formatVideoForAPI (v: DBVideoDetails, fromHost?: string): EnhancedVideo {
@ -457,6 +484,7 @@ function formatVideoForAPI (v: DBVideoDetails, fromHost?: string): EnhancedVideo
name: v.name, name: v.name,
description: v.description, description: v.description,
truncatedDescription: v.truncatedDescription,
duration: v.duration, duration: v.duration,
tags: v.tags, tags: v.tags,
@ -475,6 +503,7 @@ function formatVideoForAPI (v: DBVideoDetails, fromHost?: string): EnhancedVideo
isLocal: fromHost && fromHost === v.host, isLocal: fromHost && fromHost === v.host,
views: v.views, views: v.views,
viewers: v.viewers,
likes: v.likes, likes: v.likes,
dislikes: v.dislikes, dislikes: v.dislikes,
@ -492,3 +521,9 @@ export {
formatVideoForAPI, formatVideoForAPI,
buildVideosMapping 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 { 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 { AdditionalActorAttributes } from '../../../types/actor.model'
import { formatActorImageForDB } from './' import { formatActorImageForDB } from './'
import { buildActorImageMapping, formatActorImageForAPI, formatActorImagesForAPI, formatActorImagesForDB } from './elastic-search-avatar' 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 { 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' import { buildUrl } from '../../../helpers/utils'
function formatActorImageForAPI (image?: ActorImage) { function formatActorImageForAPI (image?: ActorImage) {

View File

@ -1,5 +1,5 @@
import { IndexablePlaylist } from 'server/types/playlist.model' 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 { doRequestWithRetries } from '../../helpers/requests'
import { INDEXER_COUNT, REQUESTS } from '../../initializers/constants' import { INDEXER_COUNT, REQUESTS } from '../../initializers/constants'
import { IndexableChannel } from '../../types/channel.model' 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 = { export type AdditionalActorAttributes = {
handle: string 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 { ActorImageExtended, AdditionalActorAttributes } from './actor.model'
import { IndexableDoc } from './indexable-doc.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 { AdditionalActorAttributes } from './actor.model'
import { IndexableDoc } from './indexable-doc.model' import { IndexableDoc } from './indexable-doc.model'

View File

@ -1,6 +1,4 @@
import { import { VideoChannelsSearchQuery as PeerTubeChannelsSearchQuery } from '@peertube/peertube-types'
VideoChannelsSearchQuery as PeerTubeChannelsSearchQuery
} from '../../../PeerTube/shared/models/search/video-channels-search-query.model'
import { CommonSearch } from './common-search.model' import { CommonSearch } from './common-search.model'
export type ChannelsSearchQuery = PeerTubeChannelsSearchQuery & CommonSearch 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' import { CommonSearch } from './common-search.model'
export type PlaylistsSearchQuery = PeerTubePlaylistsSearchQuery & CommonSearch 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' import { CommonSearch } from './common-search.model'
export type VideosSearchQuery = Omit<PeerTubeVideosSearchQuery, 'skipCount' | 'filter'> & CommonSearch & { boostLanguages: string[] } 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/peertube-types'
import { Account, AccountSummary, Video, VideoChannel, VideoChannelSummary, VideoDetails } from '../../PeerTube/shared/models'
import { AdditionalActorAttributes } from './actor.model' import { AdditionalActorAttributes } from './actor.model'
import { IndexableDoc } from './indexable-doc.model' import { IndexableDoc } from './indexable-doc.model'

View File

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

2170
yarn.lock

File diff suppressed because it is too large Load Diff