@valbuild/server 0.99.0 → 0.99.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ValidationError } from "@valbuild/core";
|
|
2
|
-
export declare function getValidationErrorFileRef(validationError: ValidationError):
|
|
2
|
+
export declare function getValidationErrorFileRef(validationError: ValidationError): any;
|
|
@@ -1187,14 +1187,24 @@ class Service {
|
|
|
1187
1187
|
const schema = this.extracted.schemas[moduleFilePath];
|
|
1188
1188
|
const serializedSchema = this.extracted.serializedSchemas[moduleFilePath];
|
|
1189
1189
|
const moduleError = this.extracted.moduleErrors.find(e => e.path === moduleFilePath);
|
|
1190
|
+
// A module whose `def()` threw is recorded WITHOUT a path: the import never
|
|
1191
|
+
// got far enough to reveal one, so it cannot be matched above. Those errors
|
|
1192
|
+
// are precisely why a module can be missing here, so report them too -
|
|
1193
|
+
// "was not found in val.modules" alone sends the reader hunting for a
|
|
1194
|
+
// registration that is already there.
|
|
1195
|
+
const unattributedModuleErrors = this.extracted.moduleErrors.filter(e => e.path === undefined);
|
|
1190
1196
|
if (source === undefined || schema === undefined || serializedSchema === undefined) {
|
|
1191
1197
|
return {
|
|
1192
1198
|
path: moduleFilePath,
|
|
1193
1199
|
errors: {
|
|
1194
1200
|
invalidModulePath: moduleFilePath,
|
|
1195
|
-
fatal: [{
|
|
1196
|
-
message:
|
|
1197
|
-
}]
|
|
1201
|
+
fatal: moduleError ? [{
|
|
1202
|
+
message: moduleError.message
|
|
1203
|
+
}] : [{
|
|
1204
|
+
message: `Module '${moduleFilePath}' was not found in val.modules`
|
|
1205
|
+
}, ...unattributedModuleErrors.map(e => ({
|
|
1206
|
+
message: e.message
|
|
1207
|
+
}))]
|
|
1198
1208
|
}
|
|
1199
1209
|
};
|
|
1200
1210
|
}
|
|
@@ -5550,6 +5560,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
5550
5560
|
// #region sources
|
|
5551
5561
|
"/sources/~": {
|
|
5552
5562
|
PUT: async req => {
|
|
5563
|
+
var _patchOps$patches;
|
|
5553
5564
|
const query = req.query;
|
|
5554
5565
|
const cookies = req.cookies;
|
|
5555
5566
|
// TODO: filter results by moduleFilePath
|
|
@@ -5607,27 +5618,34 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
5607
5618
|
const unpatchedSources = sourcesRes.sources;
|
|
5608
5619
|
// Default to true to keep the legacy contract for older clients.
|
|
5609
5620
|
// The studio client always passes false: it owns patch application
|
|
5610
|
-
// and
|
|
5621
|
+
// and validation, and treats /sources/~ as a pure un-patched read.
|
|
5611
5622
|
const applyPatches = query.apply_patches !== false;
|
|
5612
|
-
|
|
5623
|
+
// NOTE: renders are computed here even when the client applies patches
|
|
5624
|
+
// itself: the render select functions live on the Schema instances and
|
|
5625
|
+
// are not part of the serialized schema, so the client cannot derive
|
|
5626
|
+
// them. They are computed on the patched sources, so that previews
|
|
5627
|
+
// (list titles / subtitles / images) reflect the patches that apply.
|
|
5628
|
+
let patchedSources = sourcesRes.sources;
|
|
5629
|
+
if ((((_patchOps$patches = patchOps.patches) === null || _patchOps$patches === void 0 ? void 0 : _patchOps$patches.length) ?? 0) > 0) {
|
|
5613
5630
|
const onlyPatchedTreeModules = await serverOps.getSources({
|
|
5614
5631
|
...patchAnalysis,
|
|
5615
5632
|
...patchOps
|
|
5616
5633
|
});
|
|
5617
|
-
|
|
5618
|
-
sources
|
|
5619
|
-
|
|
5620
|
-
...(onlyPatchedTreeModules.sources || {})
|
|
5621
|
-
},
|
|
5622
|
-
errors: {
|
|
5623
|
-
...sourcesRes.errors,
|
|
5624
|
-
...(onlyPatchedTreeModules.errors || {})
|
|
5625
|
-
}
|
|
5634
|
+
patchedSources = {
|
|
5635
|
+
...sourcesRes.sources,
|
|
5636
|
+
...(onlyPatchedTreeModules.sources || {})
|
|
5626
5637
|
};
|
|
5638
|
+
if (applyPatches) {
|
|
5639
|
+
sourcesRes = {
|
|
5640
|
+
sources: patchedSources,
|
|
5641
|
+
errors: {
|
|
5642
|
+
...sourcesRes.errors,
|
|
5643
|
+
...(onlyPatchedTreeModules.errors || {})
|
|
5644
|
+
}
|
|
5645
|
+
};
|
|
5646
|
+
}
|
|
5627
5647
|
}
|
|
5628
|
-
const renderRes =
|
|
5629
|
-
renders: {}
|
|
5630
|
-
};
|
|
5648
|
+
const renderRes = await serverOps.getRenders(schemasRes, patchedSources);
|
|
5631
5649
|
let sourcesValidation = {
|
|
5632
5650
|
errors: {},
|
|
5633
5651
|
files: {},
|
|
@@ -1187,14 +1187,24 @@ class Service {
|
|
|
1187
1187
|
const schema = this.extracted.schemas[moduleFilePath];
|
|
1188
1188
|
const serializedSchema = this.extracted.serializedSchemas[moduleFilePath];
|
|
1189
1189
|
const moduleError = this.extracted.moduleErrors.find(e => e.path === moduleFilePath);
|
|
1190
|
+
// A module whose `def()` threw is recorded WITHOUT a path: the import never
|
|
1191
|
+
// got far enough to reveal one, so it cannot be matched above. Those errors
|
|
1192
|
+
// are precisely why a module can be missing here, so report them too -
|
|
1193
|
+
// "was not found in val.modules" alone sends the reader hunting for a
|
|
1194
|
+
// registration that is already there.
|
|
1195
|
+
const unattributedModuleErrors = this.extracted.moduleErrors.filter(e => e.path === undefined);
|
|
1190
1196
|
if (source === undefined || schema === undefined || serializedSchema === undefined) {
|
|
1191
1197
|
return {
|
|
1192
1198
|
path: moduleFilePath,
|
|
1193
1199
|
errors: {
|
|
1194
1200
|
invalidModulePath: moduleFilePath,
|
|
1195
|
-
fatal: [{
|
|
1196
|
-
message:
|
|
1197
|
-
}]
|
|
1201
|
+
fatal: moduleError ? [{
|
|
1202
|
+
message: moduleError.message
|
|
1203
|
+
}] : [{
|
|
1204
|
+
message: `Module '${moduleFilePath}' was not found in val.modules`
|
|
1205
|
+
}, ...unattributedModuleErrors.map(e => ({
|
|
1206
|
+
message: e.message
|
|
1207
|
+
}))]
|
|
1198
1208
|
}
|
|
1199
1209
|
};
|
|
1200
1210
|
}
|
|
@@ -5550,6 +5560,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
5550
5560
|
// #region sources
|
|
5551
5561
|
"/sources/~": {
|
|
5552
5562
|
PUT: async req => {
|
|
5563
|
+
var _patchOps$patches;
|
|
5553
5564
|
const query = req.query;
|
|
5554
5565
|
const cookies = req.cookies;
|
|
5555
5566
|
// TODO: filter results by moduleFilePath
|
|
@@ -5607,27 +5618,34 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
5607
5618
|
const unpatchedSources = sourcesRes.sources;
|
|
5608
5619
|
// Default to true to keep the legacy contract for older clients.
|
|
5609
5620
|
// The studio client always passes false: it owns patch application
|
|
5610
|
-
// and
|
|
5621
|
+
// and validation, and treats /sources/~ as a pure un-patched read.
|
|
5611
5622
|
const applyPatches = query.apply_patches !== false;
|
|
5612
|
-
|
|
5623
|
+
// NOTE: renders are computed here even when the client applies patches
|
|
5624
|
+
// itself: the render select functions live on the Schema instances and
|
|
5625
|
+
// are not part of the serialized schema, so the client cannot derive
|
|
5626
|
+
// them. They are computed on the patched sources, so that previews
|
|
5627
|
+
// (list titles / subtitles / images) reflect the patches that apply.
|
|
5628
|
+
let patchedSources = sourcesRes.sources;
|
|
5629
|
+
if ((((_patchOps$patches = patchOps.patches) === null || _patchOps$patches === void 0 ? void 0 : _patchOps$patches.length) ?? 0) > 0) {
|
|
5613
5630
|
const onlyPatchedTreeModules = await serverOps.getSources({
|
|
5614
5631
|
...patchAnalysis,
|
|
5615
5632
|
...patchOps
|
|
5616
5633
|
});
|
|
5617
|
-
|
|
5618
|
-
sources
|
|
5619
|
-
|
|
5620
|
-
...(onlyPatchedTreeModules.sources || {})
|
|
5621
|
-
},
|
|
5622
|
-
errors: {
|
|
5623
|
-
...sourcesRes.errors,
|
|
5624
|
-
...(onlyPatchedTreeModules.errors || {})
|
|
5625
|
-
}
|
|
5634
|
+
patchedSources = {
|
|
5635
|
+
...sourcesRes.sources,
|
|
5636
|
+
...(onlyPatchedTreeModules.sources || {})
|
|
5626
5637
|
};
|
|
5638
|
+
if (applyPatches) {
|
|
5639
|
+
sourcesRes = {
|
|
5640
|
+
sources: patchedSources,
|
|
5641
|
+
errors: {
|
|
5642
|
+
...sourcesRes.errors,
|
|
5643
|
+
...(onlyPatchedTreeModules.errors || {})
|
|
5644
|
+
}
|
|
5645
|
+
};
|
|
5646
|
+
}
|
|
5627
5647
|
}
|
|
5628
|
-
const renderRes =
|
|
5629
|
-
renders: {}
|
|
5630
|
-
};
|
|
5648
|
+
const renderRes = await serverOps.getRenders(schemasRes, patchedSources);
|
|
5631
5649
|
let sourcesValidation = {
|
|
5632
5650
|
errors: {},
|
|
5633
5651
|
files: {},
|
|
@@ -1153,14 +1153,24 @@ class Service {
|
|
|
1153
1153
|
const schema = this.extracted.schemas[moduleFilePath];
|
|
1154
1154
|
const serializedSchema = this.extracted.serializedSchemas[moduleFilePath];
|
|
1155
1155
|
const moduleError = this.extracted.moduleErrors.find(e => e.path === moduleFilePath);
|
|
1156
|
+
// A module whose `def()` threw is recorded WITHOUT a path: the import never
|
|
1157
|
+
// got far enough to reveal one, so it cannot be matched above. Those errors
|
|
1158
|
+
// are precisely why a module can be missing here, so report them too -
|
|
1159
|
+
// "was not found in val.modules" alone sends the reader hunting for a
|
|
1160
|
+
// registration that is already there.
|
|
1161
|
+
const unattributedModuleErrors = this.extracted.moduleErrors.filter(e => e.path === undefined);
|
|
1156
1162
|
if (source === undefined || schema === undefined || serializedSchema === undefined) {
|
|
1157
1163
|
return {
|
|
1158
1164
|
path: moduleFilePath,
|
|
1159
1165
|
errors: {
|
|
1160
1166
|
invalidModulePath: moduleFilePath,
|
|
1161
|
-
fatal: [{
|
|
1162
|
-
message:
|
|
1163
|
-
}]
|
|
1167
|
+
fatal: moduleError ? [{
|
|
1168
|
+
message: moduleError.message
|
|
1169
|
+
}] : [{
|
|
1170
|
+
message: `Module '${moduleFilePath}' was not found in val.modules`
|
|
1171
|
+
}, ...unattributedModuleErrors.map(e => ({
|
|
1172
|
+
message: e.message
|
|
1173
|
+
}))]
|
|
1164
1174
|
}
|
|
1165
1175
|
};
|
|
1166
1176
|
}
|
|
@@ -5516,6 +5526,7 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
5516
5526
|
// #region sources
|
|
5517
5527
|
"/sources/~": {
|
|
5518
5528
|
PUT: async req => {
|
|
5529
|
+
var _patchOps$patches;
|
|
5519
5530
|
const query = req.query;
|
|
5520
5531
|
const cookies = req.cookies;
|
|
5521
5532
|
// TODO: filter results by moduleFilePath
|
|
@@ -5573,27 +5584,34 @@ const ValServer = (valModules, options, callbacks) => {
|
|
|
5573
5584
|
const unpatchedSources = sourcesRes.sources;
|
|
5574
5585
|
// Default to true to keep the legacy contract for older clients.
|
|
5575
5586
|
// The studio client always passes false: it owns patch application
|
|
5576
|
-
// and
|
|
5587
|
+
// and validation, and treats /sources/~ as a pure un-patched read.
|
|
5577
5588
|
const applyPatches = query.apply_patches !== false;
|
|
5578
|
-
|
|
5589
|
+
// NOTE: renders are computed here even when the client applies patches
|
|
5590
|
+
// itself: the render select functions live on the Schema instances and
|
|
5591
|
+
// are not part of the serialized schema, so the client cannot derive
|
|
5592
|
+
// them. They are computed on the patched sources, so that previews
|
|
5593
|
+
// (list titles / subtitles / images) reflect the patches that apply.
|
|
5594
|
+
let patchedSources = sourcesRes.sources;
|
|
5595
|
+
if ((((_patchOps$patches = patchOps.patches) === null || _patchOps$patches === void 0 ? void 0 : _patchOps$patches.length) ?? 0) > 0) {
|
|
5579
5596
|
const onlyPatchedTreeModules = await serverOps.getSources({
|
|
5580
5597
|
...patchAnalysis,
|
|
5581
5598
|
...patchOps
|
|
5582
5599
|
});
|
|
5583
|
-
|
|
5584
|
-
sources
|
|
5585
|
-
|
|
5586
|
-
...(onlyPatchedTreeModules.sources || {})
|
|
5587
|
-
},
|
|
5588
|
-
errors: {
|
|
5589
|
-
...sourcesRes.errors,
|
|
5590
|
-
...(onlyPatchedTreeModules.errors || {})
|
|
5591
|
-
}
|
|
5600
|
+
patchedSources = {
|
|
5601
|
+
...sourcesRes.sources,
|
|
5602
|
+
...(onlyPatchedTreeModules.sources || {})
|
|
5592
5603
|
};
|
|
5604
|
+
if (applyPatches) {
|
|
5605
|
+
sourcesRes = {
|
|
5606
|
+
sources: patchedSources,
|
|
5607
|
+
errors: {
|
|
5608
|
+
...sourcesRes.errors,
|
|
5609
|
+
...(onlyPatchedTreeModules.errors || {})
|
|
5610
|
+
}
|
|
5611
|
+
};
|
|
5612
|
+
}
|
|
5593
5613
|
}
|
|
5594
|
-
const renderRes =
|
|
5595
|
-
renders: {}
|
|
5596
|
-
};
|
|
5614
|
+
const renderRes = await serverOps.getRenders(schemasRes, patchedSources);
|
|
5597
5615
|
let sourcesValidation = {
|
|
5598
5616
|
errors: {},
|
|
5599
5617
|
files: {},
|
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.99.
|
|
19
|
+
"version": "0.99.1",
|
|
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.99.
|
|
33
|
-
"@valbuild/shared": "0.99.
|
|
34
|
-
"@valbuild/ui": "0.99.
|
|
32
|
+
"@valbuild/core": "0.99.1",
|
|
33
|
+
"@valbuild/shared": "0.99.1",
|
|
34
|
+
"@valbuild/ui": "0.99.1"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=18.17.0"
|