@valbuild/server 0.103.2 → 0.105.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.
- package/dist/declarations/src/ValOps.d.ts +10 -7
- package/dist/declarations/src/getValidationErrorFileRef.d.ts +1 -1
- package/dist/declarations/src/patchStore.d.ts +6 -6
- package/dist/valbuild-server.cjs.dev.js +19 -16
- package/dist/valbuild-server.cjs.prod.js +19 -16
- package/dist/valbuild-server.esm.js +19 -16
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ import { result } from "@valbuild/core/fp";
|
|
|
3
3
|
import { JSONValue, ParentRef, Patch, PatchError } from "@valbuild/core/patch";
|
|
4
4
|
import { ValSyntaxError, ValSyntaxErrorTree } from "./patch/ts/syntax.js";
|
|
5
5
|
import { ParentPatchId } from "@valbuild/core";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ReifiedPreview } from "@valbuild/core";
|
|
7
7
|
import { ValCommit, ValDeployment } from "@valbuild/shared/internal";
|
|
8
8
|
export type BaseSha = string & {
|
|
9
9
|
readonly _tag: unique symbol;
|
|
@@ -198,16 +198,19 @@ export declare abstract class ValOps {
|
|
|
198
198
|
getSchemaSha(): Promise<SchemaSha>;
|
|
199
199
|
analyzePatches(sortedPatches: OrderedPatches["patches"], commits?: ValCommit[], currentCommitSha?: CommitSha): PatchAnalysis;
|
|
200
200
|
/**
|
|
201
|
-
* Reifies each module's
|
|
201
|
+
* Reifies each module's previews from its schema INSTANCE.
|
|
202
202
|
*
|
|
203
|
-
* Kept even though the Studio also computes
|
|
204
|
-
* user function that lives on the instance and is not part of the serialized
|
|
203
|
+
* Kept even though the Studio also computes previews client-side: a preview is
|
|
204
|
+
* a user function that lives on the instance and is not part of the serialized
|
|
205
205
|
* schema, so a host app that does not render `<ValModulesClient>` has no
|
|
206
|
-
* instances in the browser and would otherwise get no
|
|
206
|
+
* instances in the browser and would otherwise get no previews at all. See
|
|
207
207
|
* #470.
|
|
208
|
+
*
|
|
209
|
+
* A string's `render` needs none of this — it is static config that travels
|
|
210
|
+
* with the serialized schema.
|
|
208
211
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
getPreviews(schemas: Schemas, sources: Sources): Promise<{
|
|
213
|
+
previews: Record<ModuleFilePath, ReifiedPreview | null>;
|
|
211
214
|
}>;
|
|
212
215
|
getSources(analysis?: PatchAnalysis & OrderedPatches): Promise<{
|
|
213
216
|
sources: Sources;
|
|
@@ -5,4 +5,4 @@ import { ValidationError } from "@valbuild/core";
|
|
|
5
5
|
* There is no schema in hand here — a `ValidationError` carries only the value
|
|
6
6
|
* it flagged — so the shape is all there is to go on.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getValidationErrorFileRef(validationError: ValidationError):
|
|
8
|
+
export declare function getValidationErrorFileRef(validationError: ValidationError): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PatchId } from "@valbuild/core";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { AuthorId, BaseSha } from "./ValOps.js";
|
|
4
4
|
import { PatchLogEntry, PatchLogProblem } from "./patchLog.js";
|
|
@@ -32,14 +32,14 @@ export declare const FSPatch: z.ZodObject<{
|
|
|
32
32
|
patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
33
33
|
op: z.ZodLiteral<"add">;
|
|
34
34
|
path: z.ZodArray<z.ZodString>;
|
|
35
|
-
value: z.ZodType<
|
|
35
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
36
36
|
}, z.core.$strict>, z.ZodObject<{
|
|
37
37
|
op: z.ZodLiteral<"remove">;
|
|
38
38
|
path: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
39
39
|
}, z.core.$strict>, z.ZodObject<{
|
|
40
40
|
op: z.ZodLiteral<"replace">;
|
|
41
41
|
path: z.ZodArray<z.ZodString>;
|
|
42
|
-
value: z.ZodType<
|
|
42
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
43
43
|
}, z.core.$strict>, z.ZodObject<{
|
|
44
44
|
op: z.ZodLiteral<"move">;
|
|
45
45
|
from: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
@@ -51,15 +51,15 @@ export declare const FSPatch: z.ZodObject<{
|
|
|
51
51
|
}, z.core.$strict>, z.ZodObject<{
|
|
52
52
|
op: z.ZodLiteral<"test">;
|
|
53
53
|
path: z.ZodArray<z.ZodString>;
|
|
54
|
-
value: z.ZodType<
|
|
54
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
55
55
|
}, z.core.$strict>, z.ZodObject<{
|
|
56
56
|
op: z.ZodLiteral<"file">;
|
|
57
57
|
path: z.ZodArray<z.ZodString>;
|
|
58
58
|
filePath: z.ZodString;
|
|
59
|
-
value: z.ZodType<
|
|
59
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
60
60
|
remote: z.ZodBoolean;
|
|
61
61
|
nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
-
metadata: z.ZodOptional<z.ZodType<
|
|
62
|
+
metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
63
63
|
}, z.core.$strict>], "op">>;
|
|
64
64
|
patchId: z.ZodString;
|
|
65
65
|
baseSha: z.ZodString & z.ZodType<BaseSha, string, z.core.$ZodTypeInternals<BaseSha, string>>;
|
|
@@ -2045,24 +2045,27 @@ class ValOps {
|
|
|
2045
2045
|
};
|
|
2046
2046
|
}
|
|
2047
2047
|
|
|
2048
|
-
// #region
|
|
2048
|
+
// #region getPreviews
|
|
2049
2049
|
/**
|
|
2050
|
-
* Reifies each module's
|
|
2050
|
+
* Reifies each module's previews from its schema INSTANCE.
|
|
2051
2051
|
*
|
|
2052
|
-
* Kept even though the Studio also computes
|
|
2053
|
-
* user function that lives on the instance and is not part of the serialized
|
|
2052
|
+
* Kept even though the Studio also computes previews client-side: a preview is
|
|
2053
|
+
* a user function that lives on the instance and is not part of the serialized
|
|
2054
2054
|
* schema, so a host app that does not render `<ValModulesClient>` has no
|
|
2055
|
-
* instances in the browser and would otherwise get no
|
|
2055
|
+
* instances in the browser and would otherwise get no previews at all. See
|
|
2056
2056
|
* #470.
|
|
2057
|
+
*
|
|
2058
|
+
* A string's `render` needs none of this — it is static config that travels
|
|
2059
|
+
* with the serialized schema.
|
|
2057
2060
|
*/
|
|
2058
|
-
async
|
|
2059
|
-
const
|
|
2061
|
+
async getPreviews(schemas, sources) {
|
|
2062
|
+
const previews = {};
|
|
2060
2063
|
for (const [pathS, schema] of Object.entries(schemas)) {
|
|
2061
2064
|
const path = pathS;
|
|
2062
|
-
|
|
2065
|
+
previews[path] = schema["executePreview"](path, sources[path]);
|
|
2063
2066
|
}
|
|
2064
2067
|
return {
|
|
2065
|
-
|
|
2068
|
+
previews
|
|
2066
2069
|
};
|
|
2067
2070
|
}
|
|
2068
2071
|
|
|
@@ -7976,11 +7979,11 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
7976
7979
|
// The studio client always passes false: it owns patch application
|
|
7977
7980
|
// and validation, and treats /sources/~ as a pure un-patched read.
|
|
7978
7981
|
const applyPatches = query.apply_patches !== false;
|
|
7979
|
-
// NOTE:
|
|
7980
|
-
// itself: the
|
|
7981
|
-
//
|
|
7982
|
-
//
|
|
7983
|
-
//
|
|
7982
|
+
// NOTE: previews are computed here even when the client applies patches
|
|
7983
|
+
// itself: the preview functions live on the Schema instances and are not
|
|
7984
|
+
// part of the serialized schema, so the client cannot derive them. They
|
|
7985
|
+
// are computed on the patched sources, so that previews (list titles /
|
|
7986
|
+
// subtitles / images) reflect the patches that apply.
|
|
7984
7987
|
let patchedSources = sourcesRes.sources;
|
|
7985
7988
|
if ((((_patchOps$patches = patchOps.patches) === null || _patchOps$patches === void 0 ? void 0 : _patchOps$patches.length) ?? 0) > 0) {
|
|
7986
7989
|
const onlyPatchedTreeModules = await serverOps.getSources({
|
|
@@ -8001,7 +8004,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
8001
8004
|
};
|
|
8002
8005
|
}
|
|
8003
8006
|
}
|
|
8004
|
-
const
|
|
8007
|
+
const previewRes = await serverOps.getPreviews(schemasRes, patchedSources);
|
|
8005
8008
|
let sourcesValidation = {
|
|
8006
8009
|
errors: {},
|
|
8007
8010
|
files: {},
|
|
@@ -8052,7 +8055,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
8052
8055
|
// baseSource is only meaningful when the server applied patches:
|
|
8053
8056
|
// with apply_patches=false, `source` is already un-patched.
|
|
8054
8057
|
baseSource: applyPatches && hasPatches ? unpatchedSources[moduleFilePath] : undefined,
|
|
8055
|
-
|
|
8058
|
+
preview: previewRes.previews[moduleFilePath] || null,
|
|
8056
8059
|
patches: appliedPatches.length > 0 || skippedPatches.length > 0 || Object.keys(patchErrors).length > 0 ? {
|
|
8057
8060
|
applied: appliedPatches,
|
|
8058
8061
|
skipped: skippedPatches.length > 0 ? skippedPatches : undefined,
|
|
@@ -2045,24 +2045,27 @@ class ValOps {
|
|
|
2045
2045
|
};
|
|
2046
2046
|
}
|
|
2047
2047
|
|
|
2048
|
-
// #region
|
|
2048
|
+
// #region getPreviews
|
|
2049
2049
|
/**
|
|
2050
|
-
* Reifies each module's
|
|
2050
|
+
* Reifies each module's previews from its schema INSTANCE.
|
|
2051
2051
|
*
|
|
2052
|
-
* Kept even though the Studio also computes
|
|
2053
|
-
* user function that lives on the instance and is not part of the serialized
|
|
2052
|
+
* Kept even though the Studio also computes previews client-side: a preview is
|
|
2053
|
+
* a user function that lives on the instance and is not part of the serialized
|
|
2054
2054
|
* schema, so a host app that does not render `<ValModulesClient>` has no
|
|
2055
|
-
* instances in the browser and would otherwise get no
|
|
2055
|
+
* instances in the browser and would otherwise get no previews at all. See
|
|
2056
2056
|
* #470.
|
|
2057
|
+
*
|
|
2058
|
+
* A string's `render` needs none of this — it is static config that travels
|
|
2059
|
+
* with the serialized schema.
|
|
2057
2060
|
*/
|
|
2058
|
-
async
|
|
2059
|
-
const
|
|
2061
|
+
async getPreviews(schemas, sources) {
|
|
2062
|
+
const previews = {};
|
|
2060
2063
|
for (const [pathS, schema] of Object.entries(schemas)) {
|
|
2061
2064
|
const path = pathS;
|
|
2062
|
-
|
|
2065
|
+
previews[path] = schema["executePreview"](path, sources[path]);
|
|
2063
2066
|
}
|
|
2064
2067
|
return {
|
|
2065
|
-
|
|
2068
|
+
previews
|
|
2066
2069
|
};
|
|
2067
2070
|
}
|
|
2068
2071
|
|
|
@@ -7976,11 +7979,11 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
7976
7979
|
// The studio client always passes false: it owns patch application
|
|
7977
7980
|
// and validation, and treats /sources/~ as a pure un-patched read.
|
|
7978
7981
|
const applyPatches = query.apply_patches !== false;
|
|
7979
|
-
// NOTE:
|
|
7980
|
-
// itself: the
|
|
7981
|
-
//
|
|
7982
|
-
//
|
|
7983
|
-
//
|
|
7982
|
+
// NOTE: previews are computed here even when the client applies patches
|
|
7983
|
+
// itself: the preview functions live on the Schema instances and are not
|
|
7984
|
+
// part of the serialized schema, so the client cannot derive them. They
|
|
7985
|
+
// are computed on the patched sources, so that previews (list titles /
|
|
7986
|
+
// subtitles / images) reflect the patches that apply.
|
|
7984
7987
|
let patchedSources = sourcesRes.sources;
|
|
7985
7988
|
if ((((_patchOps$patches = patchOps.patches) === null || _patchOps$patches === void 0 ? void 0 : _patchOps$patches.length) ?? 0) > 0) {
|
|
7986
7989
|
const onlyPatchedTreeModules = await serverOps.getSources({
|
|
@@ -8001,7 +8004,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
8001
8004
|
};
|
|
8002
8005
|
}
|
|
8003
8006
|
}
|
|
8004
|
-
const
|
|
8007
|
+
const previewRes = await serverOps.getPreviews(schemasRes, patchedSources);
|
|
8005
8008
|
let sourcesValidation = {
|
|
8006
8009
|
errors: {},
|
|
8007
8010
|
files: {},
|
|
@@ -8052,7 +8055,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
8052
8055
|
// baseSource is only meaningful when the server applied patches:
|
|
8053
8056
|
// with apply_patches=false, `source` is already un-patched.
|
|
8054
8057
|
baseSource: applyPatches && hasPatches ? unpatchedSources[moduleFilePath] : undefined,
|
|
8055
|
-
|
|
8058
|
+
preview: previewRes.previews[moduleFilePath] || null,
|
|
8056
8059
|
patches: appliedPatches.length > 0 || skippedPatches.length > 0 || Object.keys(patchErrors).length > 0 ? {
|
|
8057
8060
|
applied: appliedPatches,
|
|
8058
8061
|
skipped: skippedPatches.length > 0 ? skippedPatches : undefined,
|
|
@@ -2011,24 +2011,27 @@ class ValOps {
|
|
|
2011
2011
|
};
|
|
2012
2012
|
}
|
|
2013
2013
|
|
|
2014
|
-
// #region
|
|
2014
|
+
// #region getPreviews
|
|
2015
2015
|
/**
|
|
2016
|
-
* Reifies each module's
|
|
2016
|
+
* Reifies each module's previews from its schema INSTANCE.
|
|
2017
2017
|
*
|
|
2018
|
-
* Kept even though the Studio also computes
|
|
2019
|
-
* user function that lives on the instance and is not part of the serialized
|
|
2018
|
+
* Kept even though the Studio also computes previews client-side: a preview is
|
|
2019
|
+
* a user function that lives on the instance and is not part of the serialized
|
|
2020
2020
|
* schema, so a host app that does not render `<ValModulesClient>` has no
|
|
2021
|
-
* instances in the browser and would otherwise get no
|
|
2021
|
+
* instances in the browser and would otherwise get no previews at all. See
|
|
2022
2022
|
* #470.
|
|
2023
|
+
*
|
|
2024
|
+
* A string's `render` needs none of this — it is static config that travels
|
|
2025
|
+
* with the serialized schema.
|
|
2023
2026
|
*/
|
|
2024
|
-
async
|
|
2025
|
-
const
|
|
2027
|
+
async getPreviews(schemas, sources) {
|
|
2028
|
+
const previews = {};
|
|
2026
2029
|
for (const [pathS, schema] of Object.entries(schemas)) {
|
|
2027
2030
|
const path = pathS;
|
|
2028
|
-
|
|
2031
|
+
previews[path] = schema["executePreview"](path, sources[path]);
|
|
2029
2032
|
}
|
|
2030
2033
|
return {
|
|
2031
|
-
|
|
2034
|
+
previews
|
|
2032
2035
|
};
|
|
2033
2036
|
}
|
|
2034
2037
|
|
|
@@ -7942,11 +7945,11 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
7942
7945
|
// The studio client always passes false: it owns patch application
|
|
7943
7946
|
// and validation, and treats /sources/~ as a pure un-patched read.
|
|
7944
7947
|
const applyPatches = query.apply_patches !== false;
|
|
7945
|
-
// NOTE:
|
|
7946
|
-
// itself: the
|
|
7947
|
-
//
|
|
7948
|
-
//
|
|
7949
|
-
//
|
|
7948
|
+
// NOTE: previews are computed here even when the client applies patches
|
|
7949
|
+
// itself: the preview functions live on the Schema instances and are not
|
|
7950
|
+
// part of the serialized schema, so the client cannot derive them. They
|
|
7951
|
+
// are computed on the patched sources, so that previews (list titles /
|
|
7952
|
+
// subtitles / images) reflect the patches that apply.
|
|
7950
7953
|
let patchedSources = sourcesRes.sources;
|
|
7951
7954
|
if ((((_patchOps$patches = patchOps.patches) === null || _patchOps$patches === void 0 ? void 0 : _patchOps$patches.length) ?? 0) > 0) {
|
|
7952
7955
|
const onlyPatchedTreeModules = await serverOps.getSources({
|
|
@@ -7967,7 +7970,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
7967
7970
|
};
|
|
7968
7971
|
}
|
|
7969
7972
|
}
|
|
7970
|
-
const
|
|
7973
|
+
const previewRes = await serverOps.getPreviews(schemasRes, patchedSources);
|
|
7971
7974
|
let sourcesValidation = {
|
|
7972
7975
|
errors: {},
|
|
7973
7976
|
files: {},
|
|
@@ -8018,7 +8021,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
8018
8021
|
// baseSource is only meaningful when the server applied patches:
|
|
8019
8022
|
// with apply_patches=false, `source` is already un-patched.
|
|
8020
8023
|
baseSource: applyPatches && hasPatches ? unpatchedSources[moduleFilePath] : undefined,
|
|
8021
|
-
|
|
8024
|
+
preview: previewRes.previews[moduleFilePath] || null,
|
|
8022
8025
|
patches: appliedPatches.length > 0 || skippedPatches.length > 0 || Object.keys(patchErrors).length > 0 ? {
|
|
8023
8026
|
applied: appliedPatches,
|
|
8024
8027
|
skipped: skippedPatches.length > 0 ? skippedPatches : undefined,
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
"types": "dist/valbuild-server.cjs.d.ts",
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.105.0",
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@prettier/sync": "^0.6.1",
|
|
22
22
|
"@types/jest": "^30.0.0"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"typescript": "^5.9.3",
|
|
30
30
|
"zod": "^4.3.5",
|
|
31
31
|
"zod-validation-error": "^5.0.0",
|
|
32
|
-
"@valbuild/core": "0.
|
|
33
|
-
"@valbuild/shared": "0.
|
|
34
|
-
"@valbuild/ui": "0.
|
|
32
|
+
"@valbuild/core": "0.105.0",
|
|
33
|
+
"@valbuild/shared": "0.105.0",
|
|
34
|
+
"@valbuild/ui": "0.105.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=18.17.0"
|