@valbuild/server 0.143.1 → 0.144.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @valbuild/server
2
2
 
3
+ ## 0.144.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#824](https://github.com/valbuild/val/pull/824) [`a641bb0`](https://github.com/valbuild/val/commit/a641bb0286756339252c53e9230d766c23fcccc6) Thanks [@freekh](https://github.com/freekh)! - `.jsonValues()` entries saved in a proposal now show at the proposal's address. Before, the page kept showing the entry as it was when the site was last built, and the Studio there showed every entry of a saved `.jsonValues()` module as empty.
8
+
9
+ ## 0.144.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [#788](https://github.com/valbuild/val/pull/788) [`a84271c`](https://github.com/valbuild/val/commit/a84271c534822071c1e428cf9990602459682d25) Thanks [@freekh](https://github.com/freekh)! - Fixes to `npx val validate` for `s.imagedir()` and `s.filedir()`, and the `s.image(galleryVal)` / `s.file(filesVal)` fields that use them:
14
+
15
+ - **`--fix` now updates every field that uses an uploaded image or file.** When `--fix` moves an entry of an `s.imagedir(dir).remote()` or `s.filedir(dir, options).remote()` to Val Remote, the entry's key changes from the local path to the remote URL. Fields that held the old path were left pointing at it, and reported "The gallery does not have an image at …" with nothing to fix it. Now `s.image(galleryVal)` and `s.file(filesVal)` fields, and images in rich text (`s.richtext({ img: s.image(galleryVal) })`), are updated in the same run. The VS Code extension's "upload to Val Remote" updates them in the same edit, including fields inside `.jsonValues()` entries, which live in their own `*.val.json` files.
16
+ - **A field that uses an image or file from a `.remote()` gallery is no longer reported as "Expected local image, but found remote".** The gallery decides whether its files are on Val Remote; the field only has to name a file the gallery has. Before, `--fix` would download the file and point the field at a path the gallery did not have.
17
+ - **Images uploaded through a field into a `.remote()` gallery.** When you upload an image through an `s.image(galleryVal)` field in Val Studio, the field stores the remote URL and the gallery stores the image under its local path. Validation now accepts this, and `useVal` / `fetchVal` now fill in the image's `width`, `height` and `mimeType` from the gallery for it, as they do for every other gallery image.
18
+ - **Errors in a gallery's keys are reported.** A remote URL in a gallery that is not `.remote()`, a remote URL that is not valid, or one outside the gallery's `dir` was silently ignored by `npx val validate`. It is now reported as an error. `--fix` does not change it: you decide whether the key or the gallery's options are wrong.
19
+ - **A file is no longer reported as valid when it still has an error.** When `--fix` fixed one error in a file and another error was left, the file could be printed as "✔ valid".
20
+
21
+ - Updated dependencies [[`a84271c`](https://github.com/valbuild/val/commit/a84271c534822071c1e428cf9990602459682d25), [`860ab2b`](https://github.com/valbuild/val/commit/860ab2b87333daf95a48215b0e4a1b44f441c878)]:
22
+ - @valbuild/core@0.144.0
23
+ - @valbuild/shared@0.144.0
24
+ - @valbuild/ui@0.144.0
25
+
3
26
  ## 0.143.1
4
27
 
5
28
  ### Patch Changes
@@ -51,6 +51,13 @@ export type ValOpsOptions = {
51
51
  * the next save's prepare -- starts from it, and the SHAs describe it.
52
52
  */
53
53
  snapshotSources?: Sources;
54
+ /**
55
+ * The `.jsonValues()` entries the same snapshot saved, by module and key:
56
+ * their content is in their own files, not in {@link snapshotSources}, which
57
+ * holds markers. The baseline those entries are read from, as a save in
58
+ * this instance would leave them (`proposalJsonEntries` in `./proposal`).
59
+ */
60
+ snapshotJsonEntries?: Map<ModuleFilePath, Map<string, JSONValue>>;
54
61
  };
55
62
  export declare abstract class ValOps {
56
63
  private readonly valModules;
@@ -101,7 +108,9 @@ export declare abstract class ValOps {
101
108
  * unlike a module source there is nothing to re-extract, because the memo was
102
109
  * never holding the content in the first place.
103
110
  *
104
- * `null` for an entry the commit deleted.
111
+ * `deleted` for an entry the commit deleted: tagged, not `null`, because an
112
+ * entry's content may itself be JSON `null` (a nullable item), and a saved
113
+ * `null` read back as "deleted" would report the entry missing.
105
114
  *
106
115
  * Never cleared: it describes what is on disk. A host rebuild makes a new
107
116
  * instance, which is the right reset. Bounded by the project's entry count,
@@ -194,7 +194,35 @@ export declare function handleVideoMetadata(ctx: FixHandlerContext): Promise<Fix
194
194
  export declare function handleRemoteFileUpload(ctx: FixHandlerContext): Promise<FixHandlerResult>;
195
195
  export declare function handleRemoteGalleryFileUpload(ctx: FixHandlerContext): Promise<FixHandlerResult>;
196
196
  export declare function handleRemoteFileDownload(ctx: FixHandlerContext): Promise<FixHandlerResult>;
197
+ /**
198
+ * `image:check-remote` / `file:check-remote`: core's "Remote image was not
199
+ * checked." — emitted for EVERY remote value of an `s.image().remote()` /
200
+ * `s.file().remote()`, wrong or not, because core cannot read the bytes or the
201
+ * ref's validation hash. It is a request to look, not a finding, so there is
202
+ * nothing to report here: `createFixPatch` does the looking (`checkRemoteRef`)
203
+ * and returns an error only for a ref that is actually wrong, with a fix where
204
+ * the ref only needs rewriting.
205
+ *
206
+ * So these stay a hand-off. Reporting core's message here instead would put an
207
+ * error on every remote image in a project, which is what the language server
208
+ * learned to stop doing (`mediaChecks.ts`).
209
+ */
197
210
  export declare function handleRemoteFileCheck(): Promise<FixHandlerResult>;
211
+ /**
212
+ * `images:check-remote` / `files:check-remote`: a gallery key that is wrong as
213
+ * a key — a remote URL in a gallery that is not `.remote()`, a ref that does
214
+ * not parse, one outside the gallery's directory (`validateMediaKey` in core).
215
+ *
216
+ * Unlike the singular codes, core emits these only when something IS wrong,
217
+ * and its message says what. There is nothing to look up and nothing to move,
218
+ * so it is reported as it is, for a person: only they know whether the key or
219
+ * the gallery's options are the mistake. It used to share the singular codes'
220
+ * handler, which hands off to `createFixPatch` — and that has no branch for a
221
+ * gallery key, so the error vanished and the module was reported valid.
222
+ *
223
+ * The same answer as `videos:check-remote`.
224
+ */
225
+ export declare function handleGalleryCheckRemote(ctx: Pick<FixHandlerContext, "validationError">): Promise<FixHandlerResult>;
198
226
  export declare function handleUniqueFolderCheck(ctx: FixHandlerContext): Promise<FixHandlerResult>;
199
227
  export declare function handleCheckAllFiles(ctx: FixHandlerContext): Promise<FixHandlerResult>;
200
228
  export declare function handleJsonValuesExtractEntry(ctx: FixHandlerContext): Promise<FixHandlerResult>;
@@ -2,7 +2,7 @@ export { createService, Service } from "./Service.js";
2
2
  export { defineExternal, ok, err, isExternalResult, EXTERNAL_RESULT, } from "./externalRecords.js";
3
3
  export type { AdapterFor, BoundExternalRecord, ExternalAuthor, ExternalBuilder, ExternalCtx, ExternalDefinition, ExternalFile, ExternalIssue, ExternalKeyPage, ExternalRecords, ExternalResult, ExternalSearchHit, ExternalSearchPage, ExternalSort, ItemOfModule, ReadonlyRecordHasNoWrites, Returns, } from "./externalRecords.js";
4
4
  export { createValApiRouter, createValServer, safeReadGit } from "./ValRouter.js";
5
- export { proposalFromEnv, proposalSnapshot } from "./proposal.js";
5
+ export { proposalFromEnv, proposalSnapshot, proposalSnapshotForReaders, } from "./proposal.js";
6
6
  export type { ValProposal } from "./proposal.js";
7
7
  export { initHandlerOptions, createValOps } from "./valServerConfig.js";
8
8
  export { resolveRemoteFileAuth } from "./valServerConfig.js";
@@ -1,4 +1,5 @@
1
1
  import type { Json, ModuleFilePath } from "@valbuild/core";
2
+ import type { JSONValue } from "@valbuild/core/patch";
2
3
  /**
3
4
  * A proposal this server runs at the address of: an editor-managed branch of
4
5
  * the project's content, served from its own copy of the content the
@@ -70,3 +71,30 @@ export declare function proposalFromEnv(env: {
70
71
  * what the snapshot holds.
71
72
  */
72
73
  export declare function proposalSnapshot(proposal: Pick<ValProposal, "modules">): Record<ModuleFilePath, Json>;
74
+ /**
75
+ * The `.jsonValues()` entries the proposal saved, by module and key.
76
+ *
77
+ * An entry's content is not in its module's Source -- that holds a marker per
78
+ * entry -- but in the entry's own `*.val.json`, and a save writes that file:
79
+ * it reaches the proposal's address as saved TEXT ({@link ValProposal.files}),
80
+ * not as Source. So the snapshot alone shows the build's entries. This is the
81
+ * other half: each saved `*.val.json`, read as the entry its module names.
82
+ *
83
+ * Which entry a file is comes from the module's `.val.ts`, whose
84
+ * `c.json(() => import("..."))` thunks name the files -- the saved text if
85
+ * the save rewrote it, else the build's own (`projectSource`). An entry whose
86
+ * module cannot be read that way is left to the build, as before: this adds
87
+ * what it can find and never fails the address.
88
+ */
89
+ export declare function proposalJsonEntries(proposal: Pick<ValProposal, "modules" | "files">, projectSource?: Record<string, string>): Map<ModuleFilePath, Map<string, JSONValue>>;
90
+ /**
91
+ * The snapshot as a page reads it: {@link proposalSnapshot}, with each saved
92
+ * `.jsonValues()` entry's content in place of its marker -- the shape a draft
93
+ * already has, where the entries it edits hold content and the rest are
94
+ * markers the readers resolve from the build. See {@link proposalJsonEntries}.
95
+ *
96
+ * For the readers only. Val's own server keeps the markers
97
+ * ({@link proposalSnapshot}): its patching works on them, and it takes the
98
+ * saved entries separately.
99
+ */
100
+ export declare function proposalSnapshotForReaders(proposal: Pick<ValProposal, "modules" | "files">, projectSource?: Record<string, string>): Record<ModuleFilePath, Json>;
@@ -52,10 +52,11 @@ export declare function filesNamedByVideoFields(service: VideoFieldService, opti
52
52
  /**
53
53
  * The patches that point every `s.video(set)` field at a set entry's new key.
54
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.
55
+ * The same walk an image or file collection's rename uses
56
+ * (`collectionReferencePatches`): one `add` on each field's `path`, so the
57
+ * description, poster, times and captions beside it are never rewritten, and
58
+ * a field of another set, or of no set, is left alone even when its path is
59
+ * the same string — it names its own file.
59
60
  */
60
61
  export declare function videosetReferencePatches(service: VideoFieldService, setModuleFilePath: ModuleFilePath, renamed: Record<string, string>): Promise<ModulePatch[]>;
61
62
  /**