Move uuid stuff in extra utils
Since it requires an external dependency
This commit is contained in:
parent
fb3c9e2bf5
commit
0628157fe9
30 changed files with 44 additions and 28 deletions
|
@ -11,6 +11,7 @@ import { ServerService } from '@app/core/server/server.service'
|
|||
import { getDevLocale, isOnDevLocale } from '@app/helpers'
|
||||
import { CustomModalComponent } from '@app/modal/custom-modal.component'
|
||||
import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager'
|
||||
import { getKeys } from '@shared/core-utils'
|
||||
import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n'
|
||||
import {
|
||||
ClientHook,
|
||||
|
@ -134,7 +135,7 @@ export class PluginService implements ClientHook {
|
|||
}
|
||||
|
||||
async translateSetting (npmName: string, setting: RegisterClientFormFieldOptions) {
|
||||
for (const key of [ 'label', 'html', 'descriptionHTML' ]) {
|
||||
for (const key of getKeys(setting, [ 'label', 'html', 'descriptionHTML' ])) {
|
||||
if (setting[key]) setting[key] = await this.translateBy(npmName, setting[key])
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div [formGroup]="form">
|
||||
<div *ngIf="form" [formGroup]="form">
|
||||
<label *ngIf="setting.label && setting.type !== 'input-checkbox'" [attr.for]="setting.name" [innerHTML]="setting.label"></label>
|
||||
|
||||
<my-peertube-checkbox
|
||||
|
|
|
@ -7,7 +7,7 @@ import { handleOAuthToken } from '@server/lib/auth/oauth'
|
|||
import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares'
|
||||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { ScopedToken } from '@shared/models/users/user-scoped-token'
|
||||
|
||||
const tokensRouter = express.Router()
|
||||
|
|
|
@ -4,7 +4,7 @@ import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'
|
|||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
|
||||
import { uuidToShort } from '@shared/core-utils'
|
||||
import { uuidToShort } from '@shared/extra-utils'
|
||||
import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
|
||||
|
|
|
@ -9,7 +9,7 @@ import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } fro
|
|||
import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live'
|
||||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import { MVideoDetails, MVideoFullLight } from '@server/types/models'
|
||||
import { buildUUID, uuidToShort } from '@shared/core-utils'
|
||||
import { buildUUID, uuidToShort } from '@shared/extra-utils'
|
||||
import { HttpStatusCode, LiveVideoCreate, LiveVideoUpdate, VideoState } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
|
|
|
@ -18,8 +18,8 @@ import { VideoPathManager } from '@server/lib/video-path-manager'
|
|||
import { buildNextVideoState } from '@server/lib/video-state'
|
||||
import { openapiOperationDoc } from '@server/middlewares/doc'
|
||||
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
|
||||
import { getLowercaseExtension, uuidToShort } from '@shared/core-utils'
|
||||
import { isAudioFile } from '@shared/extra-utils'
|
||||
import { getLowercaseExtension } from '@shared/core-utils'
|
||||
import { isAudioFile, uuidToShort } from '@shared/extra-utils'
|
||||
import { HttpStatusCode, VideoCreate, VideoResolution, VideoState } from '@shared/models'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'multer'
|
|||
import { UploadFilesForCheck } from 'express'
|
||||
import { sep } from 'path'
|
||||
import validator from 'validator'
|
||||
import { isShortUUID, shortToUUID } from '@shared/core-utils'
|
||||
import { isShortUUID, shortToUUID } from '@shared/extra-utils'
|
||||
|
||||
function exists (value: any) {
|
||||
return value !== undefined && value !== null
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { copy, readFile, remove, rename } from 'fs-extra'
|
||||
import Jimp, { read } from 'jimp'
|
||||
import { buildUUID, getLowercaseExtension } from '@shared/core-utils'
|
||||
import { getLowercaseExtension } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
|
||||
import { logger } from './logger'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'
|
||||
import { WEBSERVER } from '../constants'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
|
|
|
@ -2,7 +2,8 @@ import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activit
|
|||
import { MIMETYPES } from '@server/initializers/constants'
|
||||
import { ActorModel } from '@server/models/actor/actor'
|
||||
import { FilteredModelAttributes } from '@server/types'
|
||||
import { buildUUID, getLowercaseExtension } from '@shared/core-utils'
|
||||
import { getLowercaseExtension } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { ActivityPubActor, ActorImageType } from '@shared/models'
|
||||
|
||||
function getActorAttributesFromObject (
|
||||
|
|
|
@ -3,7 +3,8 @@ import { queue } from 'async'
|
|||
import LRUCache from 'lru-cache'
|
||||
import { join } from 'path'
|
||||
import { ActorModel } from '@server/models/actor/actor'
|
||||
import { buildUUID, getLowercaseExtension } from '@shared/core-utils'
|
||||
import { getLowercaseExtension } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { ActivityPubActorType, ActorImageType } from '@shared/models'
|
||||
import { retryTransactionWrapper } from '../helpers/database-utils'
|
||||
import { processImage } from '../helpers/image-utils'
|
||||
|
|
|
@ -2,7 +2,8 @@ import { join } from 'path'
|
|||
import { CONFIG } from '@server/initializers/config'
|
||||
import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
|
||||
import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models'
|
||||
import { buildUUID, removeFragmentedMP4Ext } from '@shared/core-utils'
|
||||
import { removeFragmentedMP4Ext } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
|
||||
// ################## Video file name ##################
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Transaction } from 'sequelize/types'
|
||||
import { UserModel } from '@server/models/user/user'
|
||||
import { MActorDefault } from '@server/types/models/actor'
|
||||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { ActivityPubActorType } from '../../shared/models/activitypub'
|
||||
import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'
|
||||
import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
MVideoFileVideo,
|
||||
MVideoUUID
|
||||
} from '@server/types/models'
|
||||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { VideoStorage } from '@shared/models'
|
||||
import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage'
|
||||
import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize'
|
||||
import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
|
||||
import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user'
|
||||
import { uuidToShort } from '@shared/core-utils'
|
||||
import { uuidToShort } from '@shared/extra-utils'
|
||||
import { UserNotification, UserNotificationType } from '@shared/models'
|
||||
import { AttributesOnly } from '@shared/typescript-utils'
|
||||
import { isBooleanValid } from '../../helpers/custom-validators/misc'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { generateMagnetUri } from '@server/helpers/webtorrent'
|
||||
import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls'
|
||||
import { VideoViews } from '@server/lib/video-views'
|
||||
import { uuidToShort } from '@shared/core-utils'
|
||||
import { uuidToShort } from '@shared/extra-utils'
|
||||
import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models'
|
||||
import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects'
|
||||
import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos'
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'
|
||||
import { buildUUID } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { AttributesOnly } from '@shared/typescript-utils'
|
||||
import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
|
||||
import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
|
||||
|
|
|
@ -18,7 +18,8 @@ import {
|
|||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import { MAccountId, MChannelId } from '@server/types/models'
|
||||
import { buildPlaylistEmbedPath, buildPlaylistWatchPath, buildUUID, pick, uuidToShort } from '@shared/core-utils'
|
||||
import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'
|
||||
import { buildUUID, uuidToShort } from '@shared/extra-utils'
|
||||
import { AttributesOnly } from '@shared/typescript-utils'
|
||||
import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
|
||||
import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
|
||||
|
|
|
@ -32,7 +32,8 @@ import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths'
|
|||
import { VideoPathManager } from '@server/lib/video-path-manager'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { ModelCache } from '@server/models/model-cache'
|
||||
import { buildVideoEmbedPath, buildVideoWatchPath, pick, uuidToShort } from '@shared/core-utils'
|
||||
import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'
|
||||
import { uuidToShort } from '@shared/extra-utils'
|
||||
import {
|
||||
ResultList,
|
||||
ThumbnailType,
|
||||
|
|
|
@ -19,7 +19,8 @@ import {
|
|||
MockSmtpServer,
|
||||
prepareNotificationsTest
|
||||
} from '@server/tests/shared'
|
||||
import { buildUUID, wait } from '@shared/core-utils'
|
||||
import { wait } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models'
|
||||
import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ import {
|
|||
prepareNotificationsTest,
|
||||
uploadRandomVideoOnServers
|
||||
} from '@server/tests/shared'
|
||||
import { buildUUID, wait } from '@shared/core-utils'
|
||||
import { wait } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'
|
||||
import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ import 'mocha'
|
|||
import * as chai from 'chai'
|
||||
import { createFile, readdir } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { buildUUID, wait } from '@shared/core-utils'
|
||||
import { wait } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
|
||||
import {
|
||||
cleanupTests,
|
||||
|
|
|
@ -10,6 +10,10 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
|
|||
return result
|
||||
}
|
||||
|
||||
function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
|
||||
return (Object.keys(object) as K[]).filter(k => keys.includes(k))
|
||||
}
|
||||
|
||||
function sortObjectComparator (key: string, order: 'asc' | 'desc') {
|
||||
return (a: any, b: any) => {
|
||||
if (a[key] < b[key]) {
|
||||
|
@ -26,5 +30,6 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') {
|
|||
|
||||
export {
|
||||
pick,
|
||||
getKeys,
|
||||
sortObjectComparator
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { VideoResolution } from "@shared/models"
|
||||
import { VideoResolution } from '@shared/models'
|
||||
|
||||
type BitPerPixel = { [ id in VideoResolution ]: number }
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
export * from './bitrate'
|
||||
export * from './privacy'
|
||||
export * from './uuid'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
export * from './crypto'
|
||||
export * from './ffprobe'
|
||||
export * from './file'
|
||||
export * from './uuid'
|
||||
|
|
|
@ -5,7 +5,8 @@ import { createReadStream, stat } from 'fs-extra'
|
|||
import got, { Response as GotResponse } from 'got'
|
||||
import { omit } from 'lodash'
|
||||
import validator from 'validator'
|
||||
import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils'
|
||||
import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import {
|
||||
HttpStatusCode,
|
||||
ResultList,
|
||||
|
|
Loading…
Reference in a new issue