@valbuild/server 0.140.0 → 0.141.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,141 @@
1
+ import { type ModuleFilePath, type SerializedRecordSchema, type SerializedSchema, type SerializedVideoSchema, type Source, type SourcePath, type ValidationError } from "@valbuild/core";
2
+ import { type Patch } from "@valbuild/core/patch";
3
+ import type { FixPatchRemainingError } from "./createFixPatch.js";
4
+ import type { FixHandlerContext, FixHandlerResult, ModulePatch } from "./fixHandlers.js";
5
+ import { type GalleryEntryKey } from "./galleryEntryKey.js";
6
+ import type { Service } from "./Service.js";
7
+ /** What of a `Service` the project-wide walks need. */
8
+ export type VideoFieldService = Pick<Service, "getModuleFilePaths" | "get">;
9
+ type ReadFile = (absolutePath: string) => Buffer | undefined;
10
+ /** See `Internal.videosetEntryVideoSchema`: the Studio hashes against it too. */
11
+ export declare function videosetEntryVideoSchema(record: SerializedRecordSchema): SerializedVideoSchema;
12
+ /**
13
+ * Every file a set entry holds: its key's file and, for an HLS stream, every
14
+ * playlist and segment its master names — read from the LOCAL copy, which a
15
+ * remote entry promoted by `--fix` still has, and which is the only place a
16
+ * stream's tree can be followed from at all.
17
+ */
18
+ export declare function filesOfVideosetEntry(entry: GalleryEntryKey, metadata: unknown, options: {
19
+ projectRoot: string;
20
+ readFile?: ReadFile;
21
+ }): string[];
22
+ /**
23
+ * The untracked files of a set's directory, sorted into the ones `--fix` can
24
+ * make entries of and the ones a person has to decide about.
25
+ *
26
+ * - `videos`: an untracked stream (keyed by its master playlist — the media
27
+ * playlists and segments it names are part of it and listed nowhere), and a
28
+ * progressive video the set accepts.
29
+ * - `others`: everything else — a poster or caption no video field names, a
30
+ * media playlist without a master, a video of a type the set does not
31
+ * accept. `--fix` does not add these: none of them is a video the set could
32
+ * hold, and deleting someone's file is not a fix.
33
+ */
34
+ export declare function classifyUntrackedVideosetFiles({ untracked, accept, projectRoot, readFile, }: {
35
+ untracked: string[];
36
+ accept: string;
37
+ projectRoot: string;
38
+ readFile?: ReadFile;
39
+ }): {
40
+ videos: string[];
41
+ others: string[];
42
+ };
43
+ /**
44
+ * The files video fields name — a video of its own, and the poster and
45
+ * captions of every field — as `/public/…` refs, a remote one by the local
46
+ * path it was uploaded from.
47
+ */
48
+ export declare function filesNamedByVideoFields(service: VideoFieldService, options: {
49
+ projectRoot: string;
50
+ readFile?: ReadFile;
51
+ }): Promise<Set<string>>;
52
+ /**
53
+ * The patches that point every `s.video(set)` field at a set entry's new key.
54
+ *
55
+ * One `add` on each field's `path`, so the description, poster, times and
56
+ * captions beside it are never rewritten. A field of another set, or of no
57
+ * set, is left alone even when its path is the same string: it names its own
58
+ * file.
59
+ */
60
+ export declare function videosetReferencePatches(service: VideoFieldService, setModuleFilePath: ModuleFilePath, renamed: Record<string, string>): Promise<ModulePatch[]>;
61
+ /**
62
+ * `videos:add-metadata`: the entry's KEY is its file, and it must be on disk
63
+ * (or on Val Remote, read over HTTP) and a kind Val can read the size and
64
+ * length of here — the same preconditions as `video:add-metadata`, asked of
65
+ * the key instead of `path`.
66
+ */
67
+ export declare function handleVideosetMetadata(ctx: FixHandlerContext): Promise<FixHandlerResult>;
68
+ /**
69
+ * `videos:check-remote`: a key that is wrong as a key — a remote URL in a set
70
+ * that is not `.remote()`, one that does not parse, one outside the set's
71
+ * directory. There is nothing to look up and nothing to move, so the error is
72
+ * reported as it is, for a person: only they know which of the set's options
73
+ * or the key is the mistake.
74
+ */
75
+ export declare function handleVideosetCheckRemote(ctx: FixHandlerContext): Promise<FixHandlerResult>;
76
+ /**
77
+ * `videos:upload-remote`: an entry of a `.remote()` set still keyed by a local
78
+ * path. Every file it holds goes up — a stream bottom-up, as the Studio places
79
+ * one — and `createFixPatch` renames the key to the ref, the same way
80
+ * `images:upload-remote` does. The fields that name the entry by its old key
81
+ * are rewritten too: without that they name a video the set no longer has.
82
+ *
83
+ * The entry's poster and captions — its defaults' files — go up with it, and
84
+ * are what is left to do for an entry whose key is already remote: the key
85
+ * stays, and the entry is written back with their refs.
86
+ */
87
+ export declare function handleVideosetUploadRemote(ctx: FixHandlerContext): Promise<FixHandlerResult>;
88
+ /**
89
+ * `videos:check-all-files`: the set's entries against its directory.
90
+ *
91
+ * What only this handler can answer is which untracked files are accounted
92
+ * for ELSEWHERE — a poster or caption a video field names — because that needs
93
+ * every module in the project. Those are fine. An untracked file that is not
94
+ * a video and that no field names is for a person to look at, and is reported
95
+ * here. Everything `--fix` can do something about — an entry whose file has
96
+ * gone, a video in the directory the set does not list — is left to
97
+ * `createFixPatch` (see {@link videosetCheckAllFilesPatch}), which reports it
98
+ * per entry, or repairs it.
99
+ */
100
+ export declare function handleVideosetCheckAllFiles(ctx: FixHandlerContext): Promise<FixHandlerResult>;
101
+ /**
102
+ * The `createFixPatch` half of `videos:check-all-files`: drop the entries
103
+ * whose file has gone, and add the videos in the directory that the set does
104
+ * not list — with what is read from their bytes, or not at all.
105
+ *
106
+ * What is stored for an entry that IS on disk is not compared against its
107
+ * bytes, unlike an image gallery's. The Studio reads a video's size and length
108
+ * in the browser from the file as it was picked, and that is not what a header
109
+ * parse of what is on disk says: a stream's largest rendition is not the
110
+ * upload's size whenever the upload was larger than the largest rendition, and
111
+ * two readers round a duration differently. Correcting one from the other
112
+ * would rewrite every streamed video in the project, every run. A missing
113
+ * value is `videos:add-metadata`'s, and is reported on the entry.
114
+ */
115
+ export declare function videosetCheckAllFilesPatch({ projectRoot, apply, sourcePath, validationError, moduleSource, moduleSchema, }: {
116
+ projectRoot: string;
117
+ apply: boolean;
118
+ sourcePath: SourcePath;
119
+ validationError: ValidationError;
120
+ moduleSource: Source | undefined;
121
+ moduleSchema: SerializedSchema | undefined;
122
+ }): Promise<{
123
+ patch: Patch;
124
+ remainingErrors: FixPatchRemainingError[];
125
+ }>;
126
+ /**
127
+ * The `createFixPatch` half of `videos:add-metadata`: read what is missing
128
+ * from the file at the entry's KEY, and write only that, one op per field —
129
+ * `alt` and anything already there are someone's, and stay.
130
+ */
131
+ export declare function videosetAddMetadataPatch({ projectRoot, sourcePath, validationError, moduleSource, moduleSchema, }: {
132
+ projectRoot: string;
133
+ sourcePath: SourcePath;
134
+ validationError: ValidationError;
135
+ moduleSource: Source | undefined;
136
+ moduleSchema: SerializedSchema | undefined;
137
+ }): Promise<{
138
+ patch: Patch;
139
+ remainingErrors: FixPatchRemainingError[];
140
+ }>;
141
+ export {};