Upgrade server dependendencies
This commit is contained in:
parent
316adda0db
commit
7cbe9e6eaf
|
@ -32,7 +32,7 @@ Add the locale in `client/src/main.ts` and `client/Makefile`. Then update transl
|
||||||
## Production
|
## Production
|
||||||
|
|
||||||
Install dependencies:
|
Install dependencies:
|
||||||
* NodeJS (v12)
|
* NodeJS (v16)
|
||||||
* Elastic Search
|
* Elastic Search
|
||||||
|
|
||||||
```terminal
|
```terminal
|
||||||
|
|
68
package.json
68
package.json
|
@ -22,52 +22,52 @@
|
||||||
"i18n:update": "cd client && git fetch weblate && git merge weblate/master && npm run gettext:extract && npm run gettext:compile"
|
"i18n:update": "cd client && git fetch weblate && git merge weblate/master && npm run gettext:extract && npm run gettext:compile"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@elastic/elasticsearch": "^7.6.0",
|
"@elastic/elasticsearch": "^8.2.1",
|
||||||
"async": "^3.1.0",
|
"async": "^3.2.3",
|
||||||
"bluebird": "^3.5.3",
|
"bluebird": "^3.5.3",
|
||||||
"body-parser": "^1.12.4",
|
"body-parser": "^1.20.0",
|
||||||
"config": "^3.0.1",
|
"config": "^3.3.7",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.16.4",
|
"express": "^4.18.1",
|
||||||
"express-validator": "^6.1.1",
|
"express-validator": "^6.14.1",
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^10.1.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"mkdirp": "^1.0.4",
|
"mkdirp": "^1.0.4",
|
||||||
"morgan": "^1.9.1",
|
"morgan": "^1.9.1",
|
||||||
"multer": "^1.4.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"pg": "^8.2.1",
|
"pg": "^8.7.3",
|
||||||
"pino": "^6.3.0",
|
"pino": "^8.0.0",
|
||||||
"pino-pretty": "^5.1.0",
|
"pino-pretty": "^8.0.0",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"retry": "^0.13.1",
|
"retry": "^0.13.1",
|
||||||
"source-map-support": "^0.5.10"
|
"source-map-support": "^0.5.21"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/async": "^3.0.0",
|
"@types/async": "^3.2.13",
|
||||||
"@types/body-parser": "^1.16.3",
|
"@types/body-parser": "^1.19.2",
|
||||||
"@types/config": "^0.0.38",
|
"@types/config": "^0.0.41",
|
||||||
"@types/express": "^4.16.1",
|
"@types/express": "^4.17.13",
|
||||||
"@types/fluent-ffmpeg": "^2.1.14",
|
"@types/fluent-ffmpeg": "^2.1.20",
|
||||||
"@types/fs-extra": "^9.0.1",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.182",
|
||||||
"@types/mkdirp": "^1.0.0",
|
"@types/mkdirp": "^1.0.2",
|
||||||
"@types/morgan": "^1.7.32",
|
"@types/morgan": "^1.9.3",
|
||||||
"@types/multer": "^1.3.3",
|
"@types/multer": "^1.4.7",
|
||||||
"@types/node": "^15.12.4",
|
"@types/node": "^17.0.38",
|
||||||
"@types/pino": "^6.0.1",
|
"@types/pino": "^7.0.5",
|
||||||
"@types/request": "^2.48.1",
|
"@types/request": "^2.48.8",
|
||||||
"@types/sequelize": "^4.27.35",
|
"@types/sequelize": "^4.28.13",
|
||||||
"@types/validator": "^13.0.0",
|
"@types/validator": "^13.7.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^4.28.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"eslint": "^7.1.0",
|
"eslint": "^8.16.0",
|
||||||
"eslint-config-standard-with-typescript": "^20.0.0",
|
"eslint-config-standard-with-typescript": "^21.0.1",
|
||||||
"eslint-plugin-import": "^2.20.1",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-node": "^11.0.0",
|
"eslint-plugin-node": "^11.0.0",
|
||||||
"eslint-plugin-promise": "^5.1.0",
|
"eslint-plugin-promise": "^6.0.0",
|
||||||
"eslint-plugin-standard": "^5.0.0",
|
"eslint-plugin-standard": "^5.0.0",
|
||||||
"typescript": "^4.3.4"
|
"typescript": "^4.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ if (isTestInstance()) {
|
||||||
require('source-map-support').install()
|
require('source-map-support').install()
|
||||||
}
|
}
|
||||||
|
|
||||||
import * as bodyParser from 'body-parser'
|
import bodyParser from 'body-parser'
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import * as cors from 'cors'
|
import cors from 'cors'
|
||||||
import * as morgan from 'morgan'
|
import morgan from 'morgan'
|
||||||
import { apiRouter } from './server/controllers/api'
|
import { apiRouter } from './server/controllers/api'
|
||||||
import { logger } from './server/helpers/logger'
|
import { logger } from './server/helpers/logger'
|
||||||
import { API_VERSION, CONFIG, getWebserverUrl } from './server/initializers/constants'
|
import { API_VERSION, CONFIG, getWebserverUrl } from './server/initializers/constants'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { ServerConfig } from '../../../shared'
|
import { ServerConfig } from '../../../shared'
|
||||||
import { CONFIG } from '../../initializers/constants'
|
import { CONFIG } from '../../initializers/constants'
|
||||||
import { IndexationScheduler } from '../../lib/schedulers/indexation-scheduler'
|
import { IndexationScheduler } from '../../lib/schedulers/indexation-scheduler'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { badRequest } from '../../helpers/utils'
|
import { badRequest } from '../../helpers/utils'
|
||||||
import { configRouter } from './config'
|
import { configRouter } from './config'
|
||||||
import { searchChannelsRouter } from './search-channels'
|
import { searchChannelsRouter } from './search-channels'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { Searcher } from '../../lib/controllers/searcher'
|
import { Searcher } from '../../lib/controllers/searcher'
|
||||||
import { formatChannelForAPI, queryChannels } from '../../lib/elastic-search/elastic-search-channels'
|
import { formatChannelForAPI, queryChannels } from '../../lib/elastic-search/elastic-search-channels'
|
||||||
import { asyncMiddleware } from '../../middlewares/async'
|
import { asyncMiddleware } from '../../middlewares/async'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { Searcher } from '../../lib/controllers/searcher'
|
import { Searcher } from '../../lib/controllers/searcher'
|
||||||
import { formatPlaylistForAPI, queryPlaylists } from '../../lib/elastic-search/elastic-search-playlists'
|
import { formatPlaylistForAPI, queryPlaylists } from '../../lib/elastic-search/elastic-search-playlists'
|
||||||
import { asyncMiddleware } from '../../middlewares/async'
|
import { asyncMiddleware } from '../../middlewares/async'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { Searcher } from '../../lib/controllers/searcher'
|
import { Searcher } from '../../lib/controllers/searcher'
|
||||||
import { formatVideoForAPI, queryVideos } from '../../lib/elastic-search/elastic-search-videos'
|
import { formatVideoForAPI, queryVideos } from '../../lib/elastic-search/elastic-search-videos'
|
||||||
import { asyncMiddleware } from '../../middlewares/async'
|
import { asyncMiddleware } from '../../middlewares/async'
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import * as Pino from 'pino'
|
import Pino from 'pino'
|
||||||
import { CONFIG } from '../initializers/constants'
|
import { CONFIG } from '../initializers/constants'
|
||||||
|
|
||||||
const pino = Pino({
|
const pino = Pino({
|
||||||
prettyPrint: true,
|
transport: {
|
||||||
|
target: 'pino-pretty'
|
||||||
|
},
|
||||||
level: CONFIG.LOG.LEVEL
|
level: CONFIG.LOG.LEVEL
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as Bluebird from 'bluebird'
|
import Bluebird from 'bluebird'
|
||||||
import * as request from 'request'
|
import request from 'request'
|
||||||
import { getWebserverUrl } from '../initializers/constants'
|
import { getWebserverUrl } from '../initializers/constants'
|
||||||
import { waitMs } from './core-utils'
|
import { waitMs } from './core-utils'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { ResultList } from '../../PeerTube/shared/models/common/result-list.model'
|
import { ResultList } from '../../PeerTube/shared/models/common/result-list.model'
|
||||||
|
|
||||||
function badRequest (req: express.Request, res: express.Response) {
|
function badRequest (req: express.Request, res: express.Response) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as config from 'config'
|
import config from 'config'
|
||||||
import { isTestInstance } from '../helpers/core-utils'
|
import { isTestInstance } from '../helpers/core-utils'
|
||||||
|
|
||||||
const API_VERSION = 'v1'
|
const API_VERSION = 'v1'
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { elasticSearch } from '../../helpers/elastic-search'
|
import { elasticSearch } from '../../helpers/elastic-search'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../../initializers/constants'
|
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../../initializers/constants'
|
||||||
import { DBChannel, EnhancedVideoChannel, IndexableChannel } from '../../types/channel.model'
|
import { DBChannel, EnhancedVideoChannel, IndexableChannel } from '../../types/channel.model'
|
||||||
import { ChannelsSearchQuery } from '../../types/search-query/channel-search.model'
|
import { ChannelsSearchQuery } from '../../types/search-query/channel-search.model'
|
||||||
import { buildSort, extractQueryResult } from './elastic-search-queries'
|
import { buildSort, extractSearchQueryResult } from './elastic-search-queries'
|
||||||
import { buildChannelOrAccountCommonMapping, buildMultiMatchBool } from './shared'
|
import { buildChannelOrAccountCommonMapping, buildMultiMatchBool } from './shared'
|
||||||
import {
|
import {
|
||||||
formatActorImageForAPI,
|
formatActorImageForAPI,
|
||||||
|
@ -75,7 +76,7 @@ async function queryChannels (search: ChannelsSearchQuery) {
|
||||||
body
|
body
|
||||||
})
|
})
|
||||||
|
|
||||||
return extractQueryResult(res)
|
return extractSearchQueryResult(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatChannelForAPI (c: DBChannel, fromHost?: string): EnhancedVideoChannel {
|
function formatChannelForAPI (c: DBChannel, fromHost?: string): EnhancedVideoChannel {
|
||||||
|
@ -187,7 +188,7 @@ function buildChannelsMapping () {
|
||||||
ownerAccount: {
|
ownerAccount: {
|
||||||
properties: buildChannelOrAccountCommonMapping()
|
properties: buildChannelOrAccountCommonMapping()
|
||||||
}
|
}
|
||||||
})
|
} as Record<PropertyName, MappingProperty>)
|
||||||
|
|
||||||
return base
|
return base
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { flatMap } from 'lodash'
|
import { flatMap } from 'lodash'
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { elasticSearch } from '../../helpers/elastic-search'
|
import { elasticSearch } from '../../helpers/elastic-search'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
import { IndexableDoc } from '../../types/indexable-doc.model'
|
import { IndexableDoc } from '../../types/indexable-doc.model'
|
||||||
|
|
||||||
function buildIndex (name: string, mapping: object) {
|
function buildIndex (name: string, mapping: Record<PropertyName, MappingProperty>) {
|
||||||
logger.info('Initialize %s Elastic Search index.', name)
|
logger.info('Initialize %s Elastic Search index.', name)
|
||||||
|
|
||||||
return elasticSearch.indices.create({
|
return elasticSearch.indices.create({
|
||||||
|
@ -63,18 +64,16 @@ async function indexDocuments <T extends IndexableDoc> (options: {
|
||||||
body
|
body
|
||||||
})
|
})
|
||||||
|
|
||||||
const resultBody = result.body
|
if (result.errors === true) {
|
||||||
|
|
||||||
if (resultBody.errors === true) {
|
|
||||||
const msg = 'Cannot insert data in elastic search.'
|
const msg = 'Cannot insert data in elastic search.'
|
||||||
logger.error({ err: resultBody }, msg)
|
logger.error({ err: result }, msg)
|
||||||
throw new Error(msg)
|
throw new Error(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
const created: T[] = result.body.items
|
const created: T[] = result.items
|
||||||
.map(i => i[method])
|
.map(i => i[method])
|
||||||
.filter(i => i.result === 'created')
|
.filter(i => i.result === 'created')
|
||||||
.map(i => elIdIndex[i._id])
|
.map(i => elIdIndex[i._id])
|
||||||
|
|
||||||
return { created }
|
return { created }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import { AggregationsStringTermsAggregate } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { elasticSearch } from '../../helpers/elastic-search'
|
import { elasticSearch } from '../../helpers/elastic-search'
|
||||||
import { CONFIG } from '../../initializers/constants'
|
import { CONFIG } from '../../initializers/constants'
|
||||||
import { listIndexInstancesHost } from '../requests/instances-index'
|
import { listIndexInstancesHost } from '../requests/instances-index'
|
||||||
|
import { extractBucketsFromAggregation } from './elastic-search-queries'
|
||||||
|
|
||||||
async function buildInstanceHosts () {
|
async function buildInstanceHosts () {
|
||||||
let indexHosts = await listIndexInstancesHost()
|
let indexHosts = await listIndexInstancesHost()
|
||||||
|
@ -33,7 +35,7 @@ async function listDBInstances () {
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const index of indexes) {
|
for (const index of indexes) {
|
||||||
const res = await elasticSearch.search({
|
const res = await elasticSearch.search<unknown, Record<'hosts', AggregationsStringTermsAggregate>>({
|
||||||
index,
|
index,
|
||||||
body: {
|
body: {
|
||||||
size: 0,
|
size: 0,
|
||||||
|
@ -48,7 +50,7 @@ async function listDBInstances () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const b of res.body.aggregations.hosts.buckets) {
|
for (const b of extractBucketsFromAggregation<string>(res.aggregations.hosts.buckets)) {
|
||||||
setResult.add(b.key)
|
setResult.add(b.key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { elasticSearch } from '../../helpers/elastic-search'
|
import { elasticSearch } from '../../helpers/elastic-search'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
import { buildUrl } from '../../helpers/utils'
|
import { buildUrl } from '../../helpers/utils'
|
||||||
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../../initializers/constants'
|
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../../initializers/constants'
|
||||||
import { DBPlaylist, EnhancedPlaylist, IndexablePlaylist } from '../../types/playlist.model'
|
import { DBPlaylist, EnhancedPlaylist, IndexablePlaylist } from '../../types/playlist.model'
|
||||||
import { PlaylistsSearchQuery } from '../../types/search-query/playlist-search.model'
|
import { PlaylistsSearchQuery } from '../../types/search-query/playlist-search.model'
|
||||||
import { buildSort, extractQueryResult } from './elastic-search-queries'
|
import { buildSort, extractSearchQueryResult } from './elastic-search-queries'
|
||||||
import { addUUIDFilters, buildMultiMatchBool } from './shared'
|
import { addUUIDFilters, buildMultiMatchBool } from './shared'
|
||||||
import { buildChannelOrAccountSummaryMapping, formatActorForDB, formatActorSummaryForAPI } from './shared/elastic-search-actor'
|
import { buildChannelOrAccountSummaryMapping, formatActorForDB, formatActorSummaryForAPI } from './shared/elastic-search-actor'
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ async function queryPlaylists (search: PlaylistsSearchQuery) {
|
||||||
body
|
body
|
||||||
})
|
})
|
||||||
|
|
||||||
return extractQueryResult(res)
|
return extractSearchQueryResult(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatPlaylistForAPI (p: DBPlaylist, fromHost?: string): EnhancedPlaylist {
|
function formatPlaylistForAPI (p: DBPlaylist, fromHost?: string): EnhancedPlaylist {
|
||||||
|
@ -216,7 +217,7 @@ function buildPlaylistsMapping () {
|
||||||
videoChannel: {
|
videoChannel: {
|
||||||
properties: buildChannelOrAccountSummaryMapping()
|
properties: buildChannelOrAccountSummaryMapping()
|
||||||
}
|
}
|
||||||
}
|
} as Record<PropertyName, MappingProperty>
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { difference } from 'lodash'
|
import { difference } from 'lodash'
|
||||||
import { ApiResponse } from '@elastic/elasticsearch'
|
import { estypes } from '@elastic/elasticsearch'
|
||||||
|
import { AggregationsBuckets, AggregationsStringTermsAggregate, AggregationsStringTermsBucket } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { elasticSearch } from '../../helpers/elastic-search'
|
import { elasticSearch } from '../../helpers/elastic-search'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ async function removeNotExistingIdsFromHost (indexName: string, host: string, ex
|
||||||
|
|
||||||
logger.info({ idsToRemove }, 'Will remove %d entries from %s of host %s.', idsToRemove.length, indexName, host)
|
logger.info({ idsToRemove }, 'Will remove %d entries from %s of host %s.', idsToRemove.length, indexName, host)
|
||||||
|
|
||||||
return elasticSearch.delete_by_query({
|
return elasticSearch.deleteByQuery({
|
||||||
index: indexName,
|
index: indexName,
|
||||||
body: {
|
body: {
|
||||||
query: {
|
query: {
|
||||||
|
@ -38,7 +39,7 @@ function removeFromHosts (indexName: string, hosts: string[]) {
|
||||||
|
|
||||||
logger.info({ hosts }, 'Will remove entries of index %s from hosts.', indexName)
|
logger.info({ hosts }, 'Will remove entries of index %s from hosts.', indexName)
|
||||||
|
|
||||||
return elasticSearch.delete_by_query({
|
return elasticSearch.deleteByQuery({
|
||||||
index: indexName,
|
index: indexName,
|
||||||
body: {
|
body: {
|
||||||
query: {
|
query: {
|
||||||
|
@ -55,7 +56,7 @@ function removeFromHosts (indexName: string, hosts: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getIdsOf (indexName: string, host: string) {
|
async function getIdsOf (indexName: string, host: string) {
|
||||||
const res = await elasticSearch.search({
|
const res = await elasticSearch.search<unknown, Record<'ids', AggregationsStringTermsAggregate>>({
|
||||||
index: indexName,
|
index: indexName,
|
||||||
body: {
|
body: {
|
||||||
size: 0,
|
size: 0,
|
||||||
|
@ -81,13 +82,21 @@ async function getIdsOf (indexName: string, host: string) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.body.aggregations.ids.buckets.map(b => b.key)
|
return extractBucketsFromAggregation<number>(res.aggregations.ids.buckets).map(b => b.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractQueryResult (result: ApiResponse<any, any>) {
|
function extractSearchQueryResult (result: estypes.SearchResponse<any, any>) {
|
||||||
const hits = result.body.hits
|
const hits = result.hits
|
||||||
|
|
||||||
return { total: hits.total.value, data: hits.hits.map(h => Object.assign(h._source, { score: h._score })) }
|
return {
|
||||||
|
total: (hits.total as estypes.SearchTotalHits).value,
|
||||||
|
data: hits.hits.map(h => Object.assign(h._source, { score: h._score }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractBucketsFromAggregation <T extends string | number> (buckets: AggregationsBuckets<AggregationsStringTermsBucket>) {
|
||||||
|
// FIXME: key returned by elastic search can also be a number
|
||||||
|
return buckets as unknown as { key: T }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSort (value: string) {
|
function buildSort (value: string) {
|
||||||
|
@ -117,7 +126,8 @@ export {
|
||||||
elasticSearch,
|
elasticSearch,
|
||||||
removeNotExistingIdsFromHost,
|
removeNotExistingIdsFromHost,
|
||||||
getIdsOf,
|
getIdsOf,
|
||||||
extractQueryResult,
|
extractSearchQueryResult,
|
||||||
removeFromHosts,
|
removeFromHosts,
|
||||||
buildSort
|
buildSort,
|
||||||
|
extractBucketsFromAggregation
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { exists } from '../../helpers/custom-validators/misc'
|
import { exists } from '../../helpers/custom-validators/misc'
|
||||||
import { elasticSearch } from '../../helpers/elastic-search'
|
import { elasticSearch } from '../../helpers/elastic-search'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
@ -5,7 +6,7 @@ import { buildUrl } from '../../helpers/utils'
|
||||||
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../../initializers/constants'
|
import { CONFIG, ELASTIC_SEARCH_QUERY } from '../../initializers/constants'
|
||||||
import { VideosSearchQuery } from '../../types/search-query/video-search.model'
|
import { VideosSearchQuery } from '../../types/search-query/video-search.model'
|
||||||
import { DBVideo, DBVideoDetails, EnhancedVideo, IndexableVideo, IndexableVideoDetails } from '../../types/video.model'
|
import { DBVideo, DBVideoDetails, EnhancedVideo, IndexableVideo, IndexableVideoDetails } from '../../types/video.model'
|
||||||
import { buildSort, extractQueryResult } from './elastic-search-queries'
|
import { buildSort, extractSearchQueryResult } from './elastic-search-queries'
|
||||||
import { addUUIDFilters, buildMultiMatchBool } from './shared'
|
import { addUUIDFilters, buildMultiMatchBool } from './shared'
|
||||||
import { buildChannelOrAccountSummaryMapping, formatActorForDB, formatActorSummaryForAPI } from './shared/elastic-search-actor'
|
import { buildChannelOrAccountSummaryMapping, formatActorForDB, formatActorSummaryForAPI } from './shared/elastic-search-actor'
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ async function queryVideos (search: VideosSearchQuery) {
|
||||||
body
|
body
|
||||||
})
|
})
|
||||||
|
|
||||||
return extractQueryResult(res)
|
return extractSearchQueryResult(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildVideosMapping () {
|
function buildVideosMapping () {
|
||||||
|
@ -368,7 +369,7 @@ function buildVideosMapping () {
|
||||||
channel: {
|
channel: {
|
||||||
properties: buildChannelOrAccountSummaryMapping()
|
properties: buildChannelOrAccountSummaryMapping()
|
||||||
}
|
}
|
||||||
}
|
} as Record<PropertyName, MappingProperty>
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo | DBVideoDetails {
|
function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo | DBVideoDetails {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { AccountSummary, VideoChannelSummary } from '../../../../PeerTube/shared/models'
|
import { AccountSummary, VideoChannelSummary } from '../../../../PeerTube/shared/models'
|
||||||
import { AdditionalActorAttributes } from '../../../types/actor.model'
|
import { AdditionalActorAttributes } from '../../../types/actor.model'
|
||||||
import { formatActorImageForDB } from './'
|
import { formatActorImageForDB } from './'
|
||||||
|
@ -38,7 +39,7 @@ function buildChannelOrAccountSummaryMapping () {
|
||||||
avatars: {
|
avatars: {
|
||||||
properties: buildActorImageMapping()
|
properties: buildActorImageMapping()
|
||||||
}
|
}
|
||||||
}
|
} as Record<PropertyName, MappingProperty>
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildChannelOrAccountCommonMapping () {
|
function buildChannelOrAccountCommonMapping () {
|
||||||
|
@ -64,7 +65,7 @@ function buildChannelOrAccountCommonMapping () {
|
||||||
description: {
|
description: {
|
||||||
type: 'text'
|
type: 'text'
|
||||||
}
|
}
|
||||||
}
|
} as Record<PropertyName, MappingProperty>
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatActorSummaryForAPI (actor: (AccountSummary | VideoChannelSummary) & AdditionalActorAttributes) {
|
function formatActorSummaryForAPI (actor: (AccountSummary | VideoChannelSummary) & AdditionalActorAttributes) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { ActorImage } from '../../../../PeerTube/shared/models'
|
import { ActorImage } from '../../../../PeerTube/shared/models'
|
||||||
import { buildUrl } from '../../../helpers/utils'
|
import { buildUrl } from '../../../helpers/utils'
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ function buildActorImageMapping () {
|
||||||
type: 'date',
|
type: 'date',
|
||||||
format: 'date_optional_time'
|
format: 'date_optional_time'
|
||||||
}
|
}
|
||||||
}
|
} as Record<PropertyName, MappingProperty>
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { ELASTIC_SEARCH_QUERY } from '../../../initializers/constants'
|
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
|
|
||||||
|
import { ELASTIC_SEARCH_QUERY } from '../../../initializers/constants'
|
||||||
|
|
||||||
function addUUIDFilters (filters: any[], uuids: string[]) {
|
function addUUIDFilters (filters: any[], uuids: string[]) {
|
||||||
if (!filters) return
|
if (!filters) return
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { AsyncQueue, queue } from 'async'
|
import { AsyncQueue, queue } from 'async'
|
||||||
import { inspect } from 'util'
|
import { inspect } from 'util'
|
||||||
|
import { MappingProperty, PropertyName } from '@elastic/elasticsearch/lib/api/types'
|
||||||
import { logger } from '../../../helpers/logger'
|
import { logger } from '../../../helpers/logger'
|
||||||
import { INDEXER_QUEUE_CONCURRENCY } from '../../../initializers/constants'
|
import { INDEXER_QUEUE_CONCURRENCY } from '../../../initializers/constants'
|
||||||
import { buildIndex, indexDocuments, refreshIndex } from '../../../lib/elastic-search/elastic-search-index'
|
import { buildIndex, indexDocuments, refreshIndex } from '../../../lib/elastic-search/elastic-search-index'
|
||||||
|
@ -13,7 +14,7 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
|
||||||
protected readonly indexQueue: AsyncQueue<QueueParam>
|
protected readonly indexQueue: AsyncQueue<QueueParam>
|
||||||
|
|
||||||
abstract indexSpecificElement (host: string, uuid: string): Promise<any>
|
abstract indexSpecificElement (host: string, uuid: string): Promise<any>
|
||||||
abstract buildMapping (): object
|
abstract buildMapping (): Record<PropertyName, MappingProperty>
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
protected readonly indexName: string,
|
protected readonly indexName: string,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
import * as Bluebird from 'bluebird'
|
import Bluebird from 'bluebird'
|
||||||
import { inspect } from 'util'
|
import { inspect } from 'util'
|
||||||
|
|
||||||
export abstract class AbstractScheduler {
|
export abstract class AbstractScheduler {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as Bluebird from 'bluebird'
|
import Bluebird from 'bluebird'
|
||||||
import { IndexablePlaylist } from 'server/types/playlist.model'
|
import { IndexablePlaylist } from 'server/types/playlist.model'
|
||||||
import { inspect } from 'util'
|
import { inspect } from 'util'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'express-validator'
|
import 'express-validator'
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { PAGINATION_COUNT } from '../initializers/constants'
|
import { PAGINATION_COUNT } from '../initializers/constants'
|
||||||
|
|
||||||
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
|
|
||||||
const setDefaultSort = setDefaultSortFactory('-createdAt')
|
const setDefaultSort = setDefaultSortFactory('-createdAt')
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
|
|
||||||
const methodsValidator = (methods: string[]) => {
|
const methodsValidator = (methods: string[]) => {
|
||||||
return (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
return (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { check } from 'express-validator'
|
import { check } from 'express-validator'
|
||||||
import { PAGINATION_COUNT, PAGINATION_START } from '../../initializers/constants'
|
import { PAGINATION_COUNT, PAGINATION_START } from '../../initializers/constants'
|
||||||
import { areValidationErrors } from './utils'
|
import { areValidationErrors } from './utils'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { check } from 'express-validator'
|
import { check } from 'express-validator'
|
||||||
import { isDateValid, toArray } from '../../helpers/custom-validators/misc'
|
import { isDateValid, toArray } from '../../helpers/custom-validators/misc'
|
||||||
import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../helpers/custom-validators/search-videos'
|
import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../helpers/custom-validators/search-videos'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as express from 'express'
|
import express from 'express'
|
||||||
import { check, validationResult } from 'express-validator'
|
import { check, validationResult } from 'express-validator'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"lib": [
|
"lib": [
|
||||||
"dom",
|
"dom",
|
||||||
|
|
Loading…
Reference in New Issue