@valbuild/server 0.72.1 → 0.72.2
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.
@@ -1682,6 +1682,33 @@ class ValOps {
|
|
1682
1682
|
|
1683
1683
|
// #region validateSources
|
1684
1684
|
async validateSources(schemas, sources, patchesByModule) {
|
1685
|
+
const checkKeyIsValid = async (key, sourcePath) => {
|
1686
|
+
var _schemas$moduleFilePa;
|
1687
|
+
const [moduleFilePath] = core.Internal.splitModuleFilePathAndModulePath(sourcePath);
|
1688
|
+
const keyOfModuleSource = sources[moduleFilePath];
|
1689
|
+
const keyOfModuleSchema = (_schemas$moduleFilePa = schemas[moduleFilePath]) === null || _schemas$moduleFilePa === void 0 ? void 0 : _schemas$moduleFilePa.serialize();
|
1690
|
+
if (keyOfModuleSchema && keyOfModuleSchema.type !== "record") {
|
1691
|
+
return {
|
1692
|
+
error: true,
|
1693
|
+
message: `Expected key at ${sourcePath} to be of type 'record'`
|
1694
|
+
};
|
1695
|
+
}
|
1696
|
+
if (keyOfModuleSource && typeof keyOfModuleSource === "object" && key in keyOfModuleSource) {
|
1697
|
+
return {
|
1698
|
+
error: false
|
1699
|
+
};
|
1700
|
+
}
|
1701
|
+
if (!keyOfModuleSource || typeof keyOfModuleSource !== "object") {
|
1702
|
+
return {
|
1703
|
+
error: true,
|
1704
|
+
message: `Expected ${sourcePath} to be a truthy object`
|
1705
|
+
};
|
1706
|
+
}
|
1707
|
+
return {
|
1708
|
+
error: true,
|
1709
|
+
message: `Key '${key}' does not exist in ${sourcePath}.`
|
1710
|
+
};
|
1711
|
+
};
|
1685
1712
|
const errors = {};
|
1686
1713
|
const files = {};
|
1687
1714
|
const entries = Object.entries(schemas);
|
@@ -1712,8 +1739,20 @@ class ValOps {
|
|
1712
1739
|
}
|
1713
1740
|
for (const [sourcePathS, validationErrors] of Object.entries(res)) {
|
1714
1741
|
const sourcePath = sourcePathS;
|
1742
|
+
const addError = validationError => {
|
1743
|
+
if (!errors[path]) {
|
1744
|
+
errors[path] = {
|
1745
|
+
validations: {}
|
1746
|
+
};
|
1747
|
+
}
|
1748
|
+
if (!errors[path].validations[sourcePath]) {
|
1749
|
+
errors[path].validations[sourcePath] = [];
|
1750
|
+
}
|
1751
|
+
errors[path].validations[sourcePath].push(validationError);
|
1752
|
+
};
|
1715
1753
|
if (validationErrors) {
|
1716
1754
|
for (const validationError of validationErrors) {
|
1755
|
+
var _validationError$fixe;
|
1717
1756
|
if (isOnlyFileCheckValidationError(validationError)) {
|
1718
1757
|
if (files[sourcePath]) {
|
1719
1758
|
throw new Error("Cannot have multiple files with same path. Path: " + sourcePath + "; Module: " + path);
|
@@ -1722,16 +1761,48 @@ class ValOps {
|
|
1722
1761
|
if (isFileSource(value)) {
|
1723
1762
|
files[sourcePath] = value;
|
1724
1763
|
}
|
1725
|
-
} else {
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1764
|
+
} else if ((_validationError$fixe = validationError.fixes) !== null && _validationError$fixe !== void 0 && _validationError$fixe.includes("keyof:check-keys")) {
|
1765
|
+
const TYPE_ERROR_MESSAGE = `This is most likely a Val version mismatch or Val bug.`;
|
1766
|
+
if (!validationError.value) {
|
1767
|
+
addError({
|
1768
|
+
message: `Could not find a value for keyOf at ${sourcePath}. ${TYPE_ERROR_MESSAGE}`,
|
1769
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1770
|
+
typeError: true
|
1771
|
+
});
|
1772
|
+
} else {
|
1773
|
+
if (typeof validationError.value !== "object") {
|
1774
|
+
addError({
|
1775
|
+
message: `Expected keyOf validation error to have a 'value' property of type 'object'. Found: ${typeof validationError.value}. ${TYPE_ERROR_MESSAGE}`,
|
1776
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1777
|
+
typeError: true
|
1778
|
+
});
|
1779
|
+
} else {
|
1780
|
+
const key = "key" in validationError.value && validationError.value.key;
|
1781
|
+
const validationErrorSourcePath = "sourcePath" in validationError.value && validationError.value.sourcePath;
|
1782
|
+
if (typeof key !== "string") {
|
1783
|
+
addError({
|
1784
|
+
message: `Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ${typeof key}. ${TYPE_ERROR_MESSAGE}`,
|
1785
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1786
|
+
typeError: true
|
1787
|
+
});
|
1788
|
+
} else if (typeof validationErrorSourcePath !== "string") {
|
1789
|
+
addError({
|
1790
|
+
message: `Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ${typeof validationErrorSourcePath}. ${TYPE_ERROR_MESSAGE}`,
|
1791
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1792
|
+
typeError: true
|
1793
|
+
});
|
1794
|
+
} else {
|
1795
|
+
const res = await checkKeyIsValid(key, validationErrorSourcePath);
|
1796
|
+
if (res.error) {
|
1797
|
+
addError({
|
1798
|
+
message: res.message
|
1799
|
+
});
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
}
|
1733
1803
|
}
|
1734
|
-
|
1804
|
+
} else {
|
1805
|
+
addError(validationError);
|
1735
1806
|
}
|
1736
1807
|
}
|
1737
1808
|
}
|
@@ -2229,8 +2300,8 @@ class ValOps {
|
|
2229
2300
|
// #region abstract ops
|
2230
2301
|
}
|
2231
2302
|
function isOnlyFileCheckValidationError(validationError) {
|
2232
|
-
var _validationError$
|
2233
|
-
if ((_validationError$
|
2303
|
+
var _validationError$fixe2;
|
2304
|
+
if ((_validationError$fixe2 = validationError.fixes) !== null && _validationError$fixe2 !== void 0 && _validationError$fixe2.every(f => f === "file:check-metadata" || f === "image:check-metadata")) {
|
2234
2305
|
return true;
|
2235
2306
|
}
|
2236
2307
|
return false;
|
@@ -1682,6 +1682,33 @@ class ValOps {
|
|
1682
1682
|
|
1683
1683
|
// #region validateSources
|
1684
1684
|
async validateSources(schemas, sources, patchesByModule) {
|
1685
|
+
const checkKeyIsValid = async (key, sourcePath) => {
|
1686
|
+
var _schemas$moduleFilePa;
|
1687
|
+
const [moduleFilePath] = core.Internal.splitModuleFilePathAndModulePath(sourcePath);
|
1688
|
+
const keyOfModuleSource = sources[moduleFilePath];
|
1689
|
+
const keyOfModuleSchema = (_schemas$moduleFilePa = schemas[moduleFilePath]) === null || _schemas$moduleFilePa === void 0 ? void 0 : _schemas$moduleFilePa.serialize();
|
1690
|
+
if (keyOfModuleSchema && keyOfModuleSchema.type !== "record") {
|
1691
|
+
return {
|
1692
|
+
error: true,
|
1693
|
+
message: `Expected key at ${sourcePath} to be of type 'record'`
|
1694
|
+
};
|
1695
|
+
}
|
1696
|
+
if (keyOfModuleSource && typeof keyOfModuleSource === "object" && key in keyOfModuleSource) {
|
1697
|
+
return {
|
1698
|
+
error: false
|
1699
|
+
};
|
1700
|
+
}
|
1701
|
+
if (!keyOfModuleSource || typeof keyOfModuleSource !== "object") {
|
1702
|
+
return {
|
1703
|
+
error: true,
|
1704
|
+
message: `Expected ${sourcePath} to be a truthy object`
|
1705
|
+
};
|
1706
|
+
}
|
1707
|
+
return {
|
1708
|
+
error: true,
|
1709
|
+
message: `Key '${key}' does not exist in ${sourcePath}.`
|
1710
|
+
};
|
1711
|
+
};
|
1685
1712
|
const errors = {};
|
1686
1713
|
const files = {};
|
1687
1714
|
const entries = Object.entries(schemas);
|
@@ -1712,8 +1739,20 @@ class ValOps {
|
|
1712
1739
|
}
|
1713
1740
|
for (const [sourcePathS, validationErrors] of Object.entries(res)) {
|
1714
1741
|
const sourcePath = sourcePathS;
|
1742
|
+
const addError = validationError => {
|
1743
|
+
if (!errors[path]) {
|
1744
|
+
errors[path] = {
|
1745
|
+
validations: {}
|
1746
|
+
};
|
1747
|
+
}
|
1748
|
+
if (!errors[path].validations[sourcePath]) {
|
1749
|
+
errors[path].validations[sourcePath] = [];
|
1750
|
+
}
|
1751
|
+
errors[path].validations[sourcePath].push(validationError);
|
1752
|
+
};
|
1715
1753
|
if (validationErrors) {
|
1716
1754
|
for (const validationError of validationErrors) {
|
1755
|
+
var _validationError$fixe;
|
1717
1756
|
if (isOnlyFileCheckValidationError(validationError)) {
|
1718
1757
|
if (files[sourcePath]) {
|
1719
1758
|
throw new Error("Cannot have multiple files with same path. Path: " + sourcePath + "; Module: " + path);
|
@@ -1722,16 +1761,48 @@ class ValOps {
|
|
1722
1761
|
if (isFileSource(value)) {
|
1723
1762
|
files[sourcePath] = value;
|
1724
1763
|
}
|
1725
|
-
} else {
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1764
|
+
} else if ((_validationError$fixe = validationError.fixes) !== null && _validationError$fixe !== void 0 && _validationError$fixe.includes("keyof:check-keys")) {
|
1765
|
+
const TYPE_ERROR_MESSAGE = `This is most likely a Val version mismatch or Val bug.`;
|
1766
|
+
if (!validationError.value) {
|
1767
|
+
addError({
|
1768
|
+
message: `Could not find a value for keyOf at ${sourcePath}. ${TYPE_ERROR_MESSAGE}`,
|
1769
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1770
|
+
typeError: true
|
1771
|
+
});
|
1772
|
+
} else {
|
1773
|
+
if (typeof validationError.value !== "object") {
|
1774
|
+
addError({
|
1775
|
+
message: `Expected keyOf validation error to have a 'value' property of type 'object'. Found: ${typeof validationError.value}. ${TYPE_ERROR_MESSAGE}`,
|
1776
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1777
|
+
typeError: true
|
1778
|
+
});
|
1779
|
+
} else {
|
1780
|
+
const key = "key" in validationError.value && validationError.value.key;
|
1781
|
+
const validationErrorSourcePath = "sourcePath" in validationError.value && validationError.value.sourcePath;
|
1782
|
+
if (typeof key !== "string") {
|
1783
|
+
addError({
|
1784
|
+
message: `Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ${typeof key}. ${TYPE_ERROR_MESSAGE}`,
|
1785
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1786
|
+
typeError: true
|
1787
|
+
});
|
1788
|
+
} else if (typeof validationErrorSourcePath !== "string") {
|
1789
|
+
addError({
|
1790
|
+
message: `Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ${typeof validationErrorSourcePath}. ${TYPE_ERROR_MESSAGE}`,
|
1791
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1792
|
+
typeError: true
|
1793
|
+
});
|
1794
|
+
} else {
|
1795
|
+
const res = await checkKeyIsValid(key, validationErrorSourcePath);
|
1796
|
+
if (res.error) {
|
1797
|
+
addError({
|
1798
|
+
message: res.message
|
1799
|
+
});
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
}
|
1733
1803
|
}
|
1734
|
-
|
1804
|
+
} else {
|
1805
|
+
addError(validationError);
|
1735
1806
|
}
|
1736
1807
|
}
|
1737
1808
|
}
|
@@ -2229,8 +2300,8 @@ class ValOps {
|
|
2229
2300
|
// #region abstract ops
|
2230
2301
|
}
|
2231
2302
|
function isOnlyFileCheckValidationError(validationError) {
|
2232
|
-
var _validationError$
|
2233
|
-
if ((_validationError$
|
2303
|
+
var _validationError$fixe2;
|
2304
|
+
if ((_validationError$fixe2 = validationError.fixes) !== null && _validationError$fixe2 !== void 0 && _validationError$fixe2.every(f => f === "file:check-metadata" || f === "image:check-metadata")) {
|
2234
2305
|
return true;
|
2235
2306
|
}
|
2236
2307
|
return false;
|
@@ -1653,6 +1653,33 @@ class ValOps {
|
|
1653
1653
|
|
1654
1654
|
// #region validateSources
|
1655
1655
|
async validateSources(schemas, sources, patchesByModule) {
|
1656
|
+
const checkKeyIsValid = async (key, sourcePath) => {
|
1657
|
+
var _schemas$moduleFilePa;
|
1658
|
+
const [moduleFilePath] = Internal.splitModuleFilePathAndModulePath(sourcePath);
|
1659
|
+
const keyOfModuleSource = sources[moduleFilePath];
|
1660
|
+
const keyOfModuleSchema = (_schemas$moduleFilePa = schemas[moduleFilePath]) === null || _schemas$moduleFilePa === void 0 ? void 0 : _schemas$moduleFilePa.serialize();
|
1661
|
+
if (keyOfModuleSchema && keyOfModuleSchema.type !== "record") {
|
1662
|
+
return {
|
1663
|
+
error: true,
|
1664
|
+
message: `Expected key at ${sourcePath} to be of type 'record'`
|
1665
|
+
};
|
1666
|
+
}
|
1667
|
+
if (keyOfModuleSource && typeof keyOfModuleSource === "object" && key in keyOfModuleSource) {
|
1668
|
+
return {
|
1669
|
+
error: false
|
1670
|
+
};
|
1671
|
+
}
|
1672
|
+
if (!keyOfModuleSource || typeof keyOfModuleSource !== "object") {
|
1673
|
+
return {
|
1674
|
+
error: true,
|
1675
|
+
message: `Expected ${sourcePath} to be a truthy object`
|
1676
|
+
};
|
1677
|
+
}
|
1678
|
+
return {
|
1679
|
+
error: true,
|
1680
|
+
message: `Key '${key}' does not exist in ${sourcePath}.`
|
1681
|
+
};
|
1682
|
+
};
|
1656
1683
|
const errors = {};
|
1657
1684
|
const files = {};
|
1658
1685
|
const entries = Object.entries(schemas);
|
@@ -1683,8 +1710,20 @@ class ValOps {
|
|
1683
1710
|
}
|
1684
1711
|
for (const [sourcePathS, validationErrors] of Object.entries(res)) {
|
1685
1712
|
const sourcePath = sourcePathS;
|
1713
|
+
const addError = validationError => {
|
1714
|
+
if (!errors[path]) {
|
1715
|
+
errors[path] = {
|
1716
|
+
validations: {}
|
1717
|
+
};
|
1718
|
+
}
|
1719
|
+
if (!errors[path].validations[sourcePath]) {
|
1720
|
+
errors[path].validations[sourcePath] = [];
|
1721
|
+
}
|
1722
|
+
errors[path].validations[sourcePath].push(validationError);
|
1723
|
+
};
|
1686
1724
|
if (validationErrors) {
|
1687
1725
|
for (const validationError of validationErrors) {
|
1726
|
+
var _validationError$fixe;
|
1688
1727
|
if (isOnlyFileCheckValidationError(validationError)) {
|
1689
1728
|
if (files[sourcePath]) {
|
1690
1729
|
throw new Error("Cannot have multiple files with same path. Path: " + sourcePath + "; Module: " + path);
|
@@ -1693,16 +1732,48 @@ class ValOps {
|
|
1693
1732
|
if (isFileSource(value)) {
|
1694
1733
|
files[sourcePath] = value;
|
1695
1734
|
}
|
1696
|
-
} else {
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1735
|
+
} else if ((_validationError$fixe = validationError.fixes) !== null && _validationError$fixe !== void 0 && _validationError$fixe.includes("keyof:check-keys")) {
|
1736
|
+
const TYPE_ERROR_MESSAGE = `This is most likely a Val version mismatch or Val bug.`;
|
1737
|
+
if (!validationError.value) {
|
1738
|
+
addError({
|
1739
|
+
message: `Could not find a value for keyOf at ${sourcePath}. ${TYPE_ERROR_MESSAGE}`,
|
1740
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1741
|
+
typeError: true
|
1742
|
+
});
|
1743
|
+
} else {
|
1744
|
+
if (typeof validationError.value !== "object") {
|
1745
|
+
addError({
|
1746
|
+
message: `Expected keyOf validation error to have a 'value' property of type 'object'. Found: ${typeof validationError.value}. ${TYPE_ERROR_MESSAGE}`,
|
1747
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1748
|
+
typeError: true
|
1749
|
+
});
|
1750
|
+
} else {
|
1751
|
+
const key = "key" in validationError.value && validationError.value.key;
|
1752
|
+
const validationErrorSourcePath = "sourcePath" in validationError.value && validationError.value.sourcePath;
|
1753
|
+
if (typeof key !== "string") {
|
1754
|
+
addError({
|
1755
|
+
message: `Expected keyOf validation error 'value' to have property 'key' of type 'string'. Found: ${typeof key}. ${TYPE_ERROR_MESSAGE}`,
|
1756
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1757
|
+
typeError: true
|
1758
|
+
});
|
1759
|
+
} else if (typeof validationErrorSourcePath !== "string") {
|
1760
|
+
addError({
|
1761
|
+
message: `Expected keyOf validation error 'value' to have property 'sourcePath' of type 'string'. Found: ${typeof validationErrorSourcePath}. ${TYPE_ERROR_MESSAGE}`,
|
1762
|
+
// Not sure this is a type error, but it shouldn't happen in a normally functioning Val system
|
1763
|
+
typeError: true
|
1764
|
+
});
|
1765
|
+
} else {
|
1766
|
+
const res = await checkKeyIsValid(key, validationErrorSourcePath);
|
1767
|
+
if (res.error) {
|
1768
|
+
addError({
|
1769
|
+
message: res.message
|
1770
|
+
});
|
1771
|
+
}
|
1772
|
+
}
|
1773
|
+
}
|
1704
1774
|
}
|
1705
|
-
|
1775
|
+
} else {
|
1776
|
+
addError(validationError);
|
1706
1777
|
}
|
1707
1778
|
}
|
1708
1779
|
}
|
@@ -2200,8 +2271,8 @@ class ValOps {
|
|
2200
2271
|
// #region abstract ops
|
2201
2272
|
}
|
2202
2273
|
function isOnlyFileCheckValidationError(validationError) {
|
2203
|
-
var _validationError$
|
2204
|
-
if ((_validationError$
|
2274
|
+
var _validationError$fixe2;
|
2275
|
+
if ((_validationError$fixe2 = validationError.fixes) !== null && _validationError$fixe2 !== void 0 && _validationError$fixe2.every(f => f === "file:check-metadata" || f === "image:check-metadata")) {
|
2205
2276
|
return true;
|
2206
2277
|
}
|
2207
2278
|
return false;
|
package/package.json
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
"./package.json": "./package.json"
|
13
13
|
},
|
14
14
|
"types": "dist/valbuild-server.cjs.d.ts",
|
15
|
-
"version": "0.72.
|
15
|
+
"version": "0.72.2",
|
16
16
|
"scripts": {
|
17
17
|
"typecheck": "tsc --noEmit",
|
18
18
|
"test": "jest",
|
@@ -23,9 +23,9 @@
|
|
23
23
|
"@types/jest": "^29.2.5"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@valbuild/core": "~0.72.
|
27
|
-
"@valbuild/shared": "~0.72.
|
28
|
-
"@valbuild/ui": "~0.72.
|
26
|
+
"@valbuild/core": "~0.72.2",
|
27
|
+
"@valbuild/shared": "~0.72.2",
|
28
|
+
"@valbuild/ui": "~0.72.2",
|
29
29
|
"chokidar": "^4.0.1",
|
30
30
|
"image-size": "^1.0.2",
|
31
31
|
"minimatch": "^3.0.4",
|