From 8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 10 Mar 2020 14:39:40 +0100 Subject: Add video file metadata to download modal, via ffprobe (#2411) * Add video file metadata via ffprobe * Federate video file metadata * Add tests for file metadata generation * Complete tests for videoFile metadata federation * Lint migration and video-file for metadata * Objectify metadata from getter in ffmpeg-utils * Add metadataUrl to all videoFiles * Simplify metadata API middleware * Load playlist in videoFile when requesting metadata --- server/models/utils.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'server/models/utils.ts') diff --git a/server/models/utils.ts b/server/models/utils.ts index 674ddcbe4..06ff05864 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts @@ -3,6 +3,23 @@ import validator from 'validator' import { Col } from 'sequelize/types/lib/utils' import { literal, OrderItem } from 'sequelize' +type Primitive = string | Function | number | boolean | Symbol | undefined | null +type DeepOmitHelper = { + [P in K]: // extra level of indirection needed to trigger homomorhic behavior + T[P] extends infer TP // distribute over unions + ? TP extends Primitive + ? TP // leave primitives and functions alone + : TP extends any[] + ? DeepOmitArray // Array special handling + : DeepOmit + : never +} +type DeepOmit = T extends Primitive ? T : DeepOmitHelper> + +type DeepOmitArray = { + [P in keyof T]: DeepOmit +} + type SortType = { sortModel: string, sortValue: string } // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] @@ -193,6 +210,7 @@ function buildDirectionAndField (value: string) { // --------------------------------------------------------------------------- export { + DeepOmit, buildBlockedAccountSQL, buildLocalActorIdsIn, SortType, -- cgit v1.2.3