@valbuild/shared 0.91.4 → 0.93.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/LICENSE.md +7 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +345 -3047
- package/dist/declarations/src/internal/getErrorMessageFromUnknownJson.d.ts +2 -0
- package/dist/declarations/src/internal/index.d.ts +1 -0
- package/dist/declarations/src/internal/richtext/conversion/remirrorTypes.d.ts +96 -1078
- package/dist/declarations/src/internal/zod/Patch.d.ts +71 -9
- package/dist/declarations/src/internal/zod/ValCommit.d.ts +1 -17
- package/dist/declarations/src/internal/zod/ValDeployment.d.ts +1 -13
- package/dist/declarations/src/utils.d.ts +8 -0
- package/dist/utils-00f3e1df.esm.js +21 -0
- package/dist/utils-32bcaca2.cjs.prod.js +23 -0
- package/dist/utils-d3d8b4b5.cjs.dev.js +23 -0
- package/dist/valbuild-shared.cjs.dev.js +3 -0
- package/dist/valbuild-shared.cjs.prod.js +3 -0
- package/dist/valbuild-shared.esm.js +2 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +64 -39
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +64 -39
- package/internal/dist/valbuild-shared-internal.esm.js +64 -41
- package/package.json +13 -10
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@valbuild/core');
|
|
6
|
-
var
|
|
6
|
+
var utils = require('../../dist/utils-32bcaca2.cjs.prod.js');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var zodValidationError = require('zod-validation-error');
|
|
9
9
|
|
|
@@ -307,8 +307,8 @@ var convertToNumber = function convertToNumber(value) {
|
|
|
307
307
|
var textEncoder = new TextEncoder();
|
|
308
308
|
function convertImageNode(path, node, files, configDirectory, remoteOptions) {
|
|
309
309
|
if (node.attrs && node.attrs.src.startsWith("data:")) {
|
|
310
|
-
var binaryData =
|
|
311
|
-
var fullFileHash = core.Internal.getSHA256Hash(
|
|
310
|
+
var binaryData = utils.base64DataUrlToUint8Array(node.attrs.src);
|
|
311
|
+
var fullFileHash = core.Internal.getSHA256Hash(binaryData);
|
|
312
312
|
var mimeType = core.Internal.getMimeType(node.attrs.src);
|
|
313
313
|
if (mimeType === undefined) {
|
|
314
314
|
throw new Error("Could not detect Mime Type for image: ".concat(node.attrs.src));
|
|
@@ -906,14 +906,14 @@ function _asyncToGenerator(n) {
|
|
|
906
906
|
}
|
|
907
907
|
|
|
908
908
|
var JSONValue = zod.z.lazy(function () {
|
|
909
|
-
return zod.z.union([zod.z.string(), zod.z.number(), zod.z["boolean"](), zod.z["null"](), zod.z.array(JSONValue), zod.z.record(JSONValue)]);
|
|
909
|
+
return zod.z.union([zod.z.string(), zod.z.number(), zod.z["boolean"](), zod.z["null"](), zod.z.array(JSONValue), zod.z.record(zod.z.string(), JSONValue)]);
|
|
910
910
|
});
|
|
911
911
|
var FileOperation = function FileOperation(path) {
|
|
912
912
|
return zod.z.object({
|
|
913
913
|
op: zod.z.literal("file"),
|
|
914
914
|
path: path,
|
|
915
915
|
filePath: zod.z.string(),
|
|
916
|
-
value:
|
|
916
|
+
value: JSONValue,
|
|
917
917
|
remote: zod.z["boolean"](),
|
|
918
918
|
nestedFilePath: zod.z.array(zod.z.string()).optional(),
|
|
919
919
|
metadata: JSONValue.optional() // TODO: remove optional
|
|
@@ -954,6 +954,7 @@ var OperationJSON = zod.z.discriminatedUnion("op", [zod.z.object({
|
|
|
954
954
|
value: JSONValue
|
|
955
955
|
}).strict(), FileOperation(zod.z.string()).strict()]);
|
|
956
956
|
var PatchJSON = zod.z.array(OperationJSON);
|
|
957
|
+
var nonEmptyArray = zod.z.tuple([zod.z.string()], zod.z.string());
|
|
957
958
|
/**
|
|
958
959
|
* Raw JSON patch operation.
|
|
959
960
|
*/
|
|
@@ -963,14 +964,14 @@ var Operation = zod.z.discriminatedUnion("op", [zod.z.object({
|
|
|
963
964
|
value: JSONValue
|
|
964
965
|
}).strict(), zod.z.object({
|
|
965
966
|
op: zod.z.literal("remove"),
|
|
966
|
-
path:
|
|
967
|
+
path: nonEmptyArray
|
|
967
968
|
}).strict(), zod.z.object({
|
|
968
969
|
op: zod.z.literal("replace"),
|
|
969
970
|
path: zod.z.array(zod.z.string()),
|
|
970
971
|
value: JSONValue
|
|
971
972
|
}).strict(), zod.z.object({
|
|
972
973
|
op: zod.z.literal("move"),
|
|
973
|
-
from:
|
|
974
|
+
from: nonEmptyArray,
|
|
974
975
|
path: zod.z.array(zod.z.string())
|
|
975
976
|
}).strict(), zod.z.object({
|
|
976
977
|
op: zod.z.literal("copy"),
|
|
@@ -1035,7 +1036,7 @@ var SerializedNumberSchema = zod.z.object({
|
|
|
1035
1036
|
var SerializedObjectSchema = zod.z.lazy(function () {
|
|
1036
1037
|
return zod.z.object({
|
|
1037
1038
|
type: zod.z.literal("object"),
|
|
1038
|
-
items: zod.z.record(SerializedSchema),
|
|
1039
|
+
items: zod.z.record(zod.z.string(), SerializedSchema),
|
|
1039
1040
|
opt: zod.z["boolean"]()
|
|
1040
1041
|
});
|
|
1041
1042
|
});
|
|
@@ -1070,26 +1071,28 @@ var SerializedImageSchema = zod.z.object({
|
|
|
1070
1071
|
options: ImageOptions.optional(),
|
|
1071
1072
|
opt: zod.z["boolean"]()
|
|
1072
1073
|
});
|
|
1073
|
-
var RichTextOptions = zod.z.
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1074
|
+
var RichTextOptions = zod.z.lazy(function () {
|
|
1075
|
+
return zod.z.object({
|
|
1076
|
+
style: zod.z.object({
|
|
1077
|
+
bold: zod.z["boolean"]().optional(),
|
|
1078
|
+
italic: zod.z["boolean"]().optional(),
|
|
1079
|
+
lineThrough: zod.z["boolean"]().optional()
|
|
1080
|
+
}).optional(),
|
|
1081
|
+
block: zod.z.object({
|
|
1082
|
+
h1: zod.z["boolean"]().optional(),
|
|
1083
|
+
h2: zod.z["boolean"]().optional(),
|
|
1084
|
+
h3: zod.z["boolean"]().optional(),
|
|
1085
|
+
h4: zod.z["boolean"]().optional(),
|
|
1086
|
+
h5: zod.z["boolean"]().optional(),
|
|
1087
|
+
h6: zod.z["boolean"]().optional(),
|
|
1088
|
+
ul: zod.z["boolean"]().optional(),
|
|
1089
|
+
ol: zod.z["boolean"]().optional()
|
|
1090
|
+
}).optional(),
|
|
1091
|
+
inline: zod.z.object({
|
|
1092
|
+
a: zod.z.union([zod.z["boolean"](), SerializedRouteSchema, SerializedStringSchema]).optional(),
|
|
1093
|
+
img: zod.z.union([zod.z["boolean"](), SerializedImageSchema]).optional()
|
|
1094
|
+
}).optional()
|
|
1095
|
+
});
|
|
1093
1096
|
});
|
|
1094
1097
|
var SerializedRichTextSchema = zod.z.object({
|
|
1095
1098
|
type: zod.z.literal("richtext"),
|
|
@@ -1771,7 +1774,8 @@ var Api = {
|
|
|
1771
1774
|
path: zod.z.string().optional(),
|
|
1772
1775
|
query: {
|
|
1773
1776
|
validate_sources: onlyOneBooleanQueryParam.optional(),
|
|
1774
|
-
validate_binary_files: onlyOneBooleanQueryParam.optional()
|
|
1777
|
+
validate_binary_files: onlyOneBooleanQueryParam.optional(),
|
|
1778
|
+
exclude_patches: onlyOneBooleanQueryParam.optional()
|
|
1775
1779
|
},
|
|
1776
1780
|
cookies: {
|
|
1777
1781
|
val_session: zod.z.string().optional()
|
|
@@ -1803,9 +1807,9 @@ var Api = {
|
|
|
1803
1807
|
schemaSha: zod.z.string(),
|
|
1804
1808
|
sourcesSha: zod.z.string(),
|
|
1805
1809
|
modules: zod.z.record(ModuleFilePath, zod.z.object({
|
|
1806
|
-
render: zod.z.any(),
|
|
1810
|
+
render: zod.z.any().optional(),
|
|
1807
1811
|
// TODO: improve this type
|
|
1808
|
-
source: zod.z.any(),
|
|
1812
|
+
source: zod.z.any().optional(),
|
|
1809
1813
|
//.optional(), // TODO: Json zod type
|
|
1810
1814
|
patches: zod.z.object({
|
|
1811
1815
|
applied: zod.z.array(PatchId),
|
|
@@ -1891,7 +1895,7 @@ var Api = {
|
|
|
1891
1895
|
message: zod.z.string(),
|
|
1892
1896
|
details: zod.z.union([zod.z.object({
|
|
1893
1897
|
sourceFilePatchErrors: zod.z.record(ModuleFilePath, zod.z.array(GenericError)),
|
|
1894
|
-
binaryFilePatchErrors: zod.z.record(GenericError)
|
|
1898
|
+
binaryFilePatchErrors: zod.z.record(zod.z.string(), GenericError)
|
|
1895
1899
|
}), zod.z.array(GenericError)]).optional()
|
|
1896
1900
|
}), zod.z.object({
|
|
1897
1901
|
message: zod.z.string(),
|
|
@@ -1945,6 +1949,24 @@ var Api = {
|
|
|
1945
1949
|
* Do not change this without updating the ValRouter query parsing logic
|
|
1946
1950
|
* */
|
|
1947
1951
|
|
|
1952
|
+
function _typeof(o) {
|
|
1953
|
+
"@babel/helpers - typeof";
|
|
1954
|
+
|
|
1955
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
1956
|
+
return typeof o;
|
|
1957
|
+
} : function (o) {
|
|
1958
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1959
|
+
}, _typeof(o);
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
function getErrorMessageFromUnknownJson(json, fallback) {
|
|
1963
|
+
if (_typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
|
|
1964
|
+
return json.message;
|
|
1965
|
+
}
|
|
1966
|
+
return fallback;
|
|
1967
|
+
}
|
|
1968
|
+
var DEFAULT_ERROR_MESSAGE = "Unknown error with unknown message from server";
|
|
1969
|
+
|
|
1948
1970
|
var createValClient = function createValClient(host, config // We want to use this in the future
|
|
1949
1971
|
) {
|
|
1950
1972
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2029,7 +2051,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2029
2051
|
message: "There was an issue validating your data. This is most likely a Val bug.",
|
|
2030
2052
|
type: "client_side_validation_error",
|
|
2031
2053
|
details: {
|
|
2032
|
-
validationError: zodValidationError.
|
|
2054
|
+
validationError: zodValidationError.fromError(reqBodyResult.error).toString(),
|
|
2033
2055
|
data: anyReq.body
|
|
2034
2056
|
}
|
|
2035
2057
|
}
|
|
@@ -2046,7 +2068,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2046
2068
|
}).then(/*#__PURE__*/function () {
|
|
2047
2069
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
|
|
2048
2070
|
var _apiEndpoint$res;
|
|
2049
|
-
var contentTypeHeaders, json, valClientResult, responseResult;
|
|
2071
|
+
var contentTypeHeaders, json, valClientResult, message, responseResult;
|
|
2050
2072
|
return _regenerator().w(function (_context) {
|
|
2051
2073
|
while (1) switch (_context.n) {
|
|
2052
2074
|
case 0:
|
|
@@ -2096,12 +2118,13 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2096
2118
|
break;
|
|
2097
2119
|
}
|
|
2098
2120
|
console.error("Server responded with an error", json);
|
|
2121
|
+
message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
2099
2122
|
return _context.a(2, {
|
|
2100
2123
|
status: 500,
|
|
2101
|
-
json:
|
|
2124
|
+
json: {
|
|
2102
2125
|
type: "unknown",
|
|
2103
|
-
message:
|
|
2104
|
-
}
|
|
2126
|
+
message: message
|
|
2127
|
+
}
|
|
2105
2128
|
});
|
|
2106
2129
|
case 4:
|
|
2107
2130
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
|
@@ -2115,7 +2138,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2115
2138
|
message: "Response could not be validated. This could also be a result of mismatched Val versions.",
|
|
2116
2139
|
type: "client_side_validation_error",
|
|
2117
2140
|
details: {
|
|
2118
|
-
validationError: zodValidationError.
|
|
2141
|
+
validationError: zodValidationError.fromError(responseResult.error).toString(),
|
|
2119
2142
|
data: valClientResult
|
|
2120
2143
|
}
|
|
2121
2144
|
}
|
|
@@ -2288,7 +2311,7 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
2288
2311
|
root.page = {
|
|
2289
2312
|
fullPath: fullPath
|
|
2290
2313
|
};
|
|
2291
|
-
root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, fullPath);
|
|
2314
|
+
root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
|
|
2292
2315
|
root.moduleFilePath = moduleFilePath;
|
|
2293
2316
|
return 0; // continue
|
|
2294
2317
|
}
|
|
@@ -2533,6 +2556,7 @@ function createRegExpFromPattern(pattern) {
|
|
|
2533
2556
|
}
|
|
2534
2557
|
|
|
2535
2558
|
exports.Api = Api;
|
|
2559
|
+
exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
|
|
2536
2560
|
exports.ParentRef = ParentRef$1;
|
|
2537
2561
|
exports.Patch = Patch;
|
|
2538
2562
|
exports.PatchBlock = PatchBlock;
|
|
@@ -2560,6 +2584,7 @@ exports.ValDeployment = ValDeployment;
|
|
|
2560
2584
|
exports.createRegExpFromPattern = createRegExpFromPattern;
|
|
2561
2585
|
exports.createValClient = createValClient;
|
|
2562
2586
|
exports.filterRoutesByPatterns = filterRoutesByPatterns;
|
|
2587
|
+
exports.getErrorMessageFromUnknownJson = getErrorMessageFromUnknownJson;
|
|
2563
2588
|
exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
|
|
2564
2589
|
exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
|
|
2565
2590
|
exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Internal, FILE_REF_PROP, VAL_EXTENSION, FILE_REF_SUBTYPE_TAG } from '@valbuild/core';
|
|
2
|
-
import {
|
|
2
|
+
import { b as base64DataUrlToUint8Array } from '../../dist/utils-00f3e1df.esm.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import {
|
|
4
|
+
import { fromError } from 'zod-validation-error';
|
|
5
5
|
|
|
6
6
|
function _toPrimitive(t, r) {
|
|
7
7
|
if ("object" != typeof t || !t) return t;
|
|
@@ -303,8 +303,8 @@ var convertToNumber = function convertToNumber(value) {
|
|
|
303
303
|
var textEncoder = new TextEncoder();
|
|
304
304
|
function convertImageNode(path, node, files, configDirectory, remoteOptions) {
|
|
305
305
|
if (node.attrs && node.attrs.src.startsWith("data:")) {
|
|
306
|
-
var binaryData =
|
|
307
|
-
var fullFileHash = Internal.getSHA256Hash(
|
|
306
|
+
var binaryData = base64DataUrlToUint8Array(node.attrs.src);
|
|
307
|
+
var fullFileHash = Internal.getSHA256Hash(binaryData);
|
|
308
308
|
var mimeType = Internal.getMimeType(node.attrs.src);
|
|
309
309
|
if (mimeType === undefined) {
|
|
310
310
|
throw new Error("Could not detect Mime Type for image: ".concat(node.attrs.src));
|
|
@@ -902,14 +902,14 @@ function _asyncToGenerator(n) {
|
|
|
902
902
|
}
|
|
903
903
|
|
|
904
904
|
var JSONValue = z.lazy(function () {
|
|
905
|
-
return z.union([z.string(), z.number(), z["boolean"](), z["null"](), z.array(JSONValue), z.record(JSONValue)]);
|
|
905
|
+
return z.union([z.string(), z.number(), z["boolean"](), z["null"](), z.array(JSONValue), z.record(z.string(), JSONValue)]);
|
|
906
906
|
});
|
|
907
907
|
var FileOperation = function FileOperation(path) {
|
|
908
908
|
return z.object({
|
|
909
909
|
op: z.literal("file"),
|
|
910
910
|
path: path,
|
|
911
911
|
filePath: z.string(),
|
|
912
|
-
value:
|
|
912
|
+
value: JSONValue,
|
|
913
913
|
remote: z["boolean"](),
|
|
914
914
|
nestedFilePath: z.array(z.string()).optional(),
|
|
915
915
|
metadata: JSONValue.optional() // TODO: remove optional
|
|
@@ -950,6 +950,7 @@ var OperationJSON = z.discriminatedUnion("op", [z.object({
|
|
|
950
950
|
value: JSONValue
|
|
951
951
|
}).strict(), FileOperation(z.string()).strict()]);
|
|
952
952
|
var PatchJSON = z.array(OperationJSON);
|
|
953
|
+
var nonEmptyArray = z.tuple([z.string()], z.string());
|
|
953
954
|
/**
|
|
954
955
|
* Raw JSON patch operation.
|
|
955
956
|
*/
|
|
@@ -959,14 +960,14 @@ var Operation = z.discriminatedUnion("op", [z.object({
|
|
|
959
960
|
value: JSONValue
|
|
960
961
|
}).strict(), z.object({
|
|
961
962
|
op: z.literal("remove"),
|
|
962
|
-
path:
|
|
963
|
+
path: nonEmptyArray
|
|
963
964
|
}).strict(), z.object({
|
|
964
965
|
op: z.literal("replace"),
|
|
965
966
|
path: z.array(z.string()),
|
|
966
967
|
value: JSONValue
|
|
967
968
|
}).strict(), z.object({
|
|
968
969
|
op: z.literal("move"),
|
|
969
|
-
from:
|
|
970
|
+
from: nonEmptyArray,
|
|
970
971
|
path: z.array(z.string())
|
|
971
972
|
}).strict(), z.object({
|
|
972
973
|
op: z.literal("copy"),
|
|
@@ -1031,7 +1032,7 @@ var SerializedNumberSchema = z.object({
|
|
|
1031
1032
|
var SerializedObjectSchema = z.lazy(function () {
|
|
1032
1033
|
return z.object({
|
|
1033
1034
|
type: z.literal("object"),
|
|
1034
|
-
items: z.record(SerializedSchema),
|
|
1035
|
+
items: z.record(z.string(), SerializedSchema),
|
|
1035
1036
|
opt: z["boolean"]()
|
|
1036
1037
|
});
|
|
1037
1038
|
});
|
|
@@ -1066,26 +1067,28 @@ var SerializedImageSchema = z.object({
|
|
|
1066
1067
|
options: ImageOptions.optional(),
|
|
1067
1068
|
opt: z["boolean"]()
|
|
1068
1069
|
});
|
|
1069
|
-
var RichTextOptions = z.
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1070
|
+
var RichTextOptions = z.lazy(function () {
|
|
1071
|
+
return z.object({
|
|
1072
|
+
style: z.object({
|
|
1073
|
+
bold: z["boolean"]().optional(),
|
|
1074
|
+
italic: z["boolean"]().optional(),
|
|
1075
|
+
lineThrough: z["boolean"]().optional()
|
|
1076
|
+
}).optional(),
|
|
1077
|
+
block: z.object({
|
|
1078
|
+
h1: z["boolean"]().optional(),
|
|
1079
|
+
h2: z["boolean"]().optional(),
|
|
1080
|
+
h3: z["boolean"]().optional(),
|
|
1081
|
+
h4: z["boolean"]().optional(),
|
|
1082
|
+
h5: z["boolean"]().optional(),
|
|
1083
|
+
h6: z["boolean"]().optional(),
|
|
1084
|
+
ul: z["boolean"]().optional(),
|
|
1085
|
+
ol: z["boolean"]().optional()
|
|
1086
|
+
}).optional(),
|
|
1087
|
+
inline: z.object({
|
|
1088
|
+
a: z.union([z["boolean"](), SerializedRouteSchema, SerializedStringSchema]).optional(),
|
|
1089
|
+
img: z.union([z["boolean"](), SerializedImageSchema]).optional()
|
|
1090
|
+
}).optional()
|
|
1091
|
+
});
|
|
1089
1092
|
});
|
|
1090
1093
|
var SerializedRichTextSchema = z.object({
|
|
1091
1094
|
type: z.literal("richtext"),
|
|
@@ -1767,7 +1770,8 @@ var Api = {
|
|
|
1767
1770
|
path: z.string().optional(),
|
|
1768
1771
|
query: {
|
|
1769
1772
|
validate_sources: onlyOneBooleanQueryParam.optional(),
|
|
1770
|
-
validate_binary_files: onlyOneBooleanQueryParam.optional()
|
|
1773
|
+
validate_binary_files: onlyOneBooleanQueryParam.optional(),
|
|
1774
|
+
exclude_patches: onlyOneBooleanQueryParam.optional()
|
|
1771
1775
|
},
|
|
1772
1776
|
cookies: {
|
|
1773
1777
|
val_session: z.string().optional()
|
|
@@ -1799,9 +1803,9 @@ var Api = {
|
|
|
1799
1803
|
schemaSha: z.string(),
|
|
1800
1804
|
sourcesSha: z.string(),
|
|
1801
1805
|
modules: z.record(ModuleFilePath, z.object({
|
|
1802
|
-
render: z.any(),
|
|
1806
|
+
render: z.any().optional(),
|
|
1803
1807
|
// TODO: improve this type
|
|
1804
|
-
source: z.any(),
|
|
1808
|
+
source: z.any().optional(),
|
|
1805
1809
|
//.optional(), // TODO: Json zod type
|
|
1806
1810
|
patches: z.object({
|
|
1807
1811
|
applied: z.array(PatchId),
|
|
@@ -1887,7 +1891,7 @@ var Api = {
|
|
|
1887
1891
|
message: z.string(),
|
|
1888
1892
|
details: z.union([z.object({
|
|
1889
1893
|
sourceFilePatchErrors: z.record(ModuleFilePath, z.array(GenericError)),
|
|
1890
|
-
binaryFilePatchErrors: z.record(GenericError)
|
|
1894
|
+
binaryFilePatchErrors: z.record(z.string(), GenericError)
|
|
1891
1895
|
}), z.array(GenericError)]).optional()
|
|
1892
1896
|
}), z.object({
|
|
1893
1897
|
message: z.string(),
|
|
@@ -1941,6 +1945,24 @@ var Api = {
|
|
|
1941
1945
|
* Do not change this without updating the ValRouter query parsing logic
|
|
1942
1946
|
* */
|
|
1943
1947
|
|
|
1948
|
+
function _typeof(o) {
|
|
1949
|
+
"@babel/helpers - typeof";
|
|
1950
|
+
|
|
1951
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
1952
|
+
return typeof o;
|
|
1953
|
+
} : function (o) {
|
|
1954
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1955
|
+
}, _typeof(o);
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
function getErrorMessageFromUnknownJson(json, fallback) {
|
|
1959
|
+
if (_typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
|
|
1960
|
+
return json.message;
|
|
1961
|
+
}
|
|
1962
|
+
return fallback;
|
|
1963
|
+
}
|
|
1964
|
+
var DEFAULT_ERROR_MESSAGE = "Unknown error with unknown message from server";
|
|
1965
|
+
|
|
1944
1966
|
var createValClient = function createValClient(host, config // We want to use this in the future
|
|
1945
1967
|
) {
|
|
1946
1968
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2025,7 +2047,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2025
2047
|
message: "There was an issue validating your data. This is most likely a Val bug.",
|
|
2026
2048
|
type: "client_side_validation_error",
|
|
2027
2049
|
details: {
|
|
2028
|
-
validationError:
|
|
2050
|
+
validationError: fromError(reqBodyResult.error).toString(),
|
|
2029
2051
|
data: anyReq.body
|
|
2030
2052
|
}
|
|
2031
2053
|
}
|
|
@@ -2042,7 +2064,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2042
2064
|
}).then(/*#__PURE__*/function () {
|
|
2043
2065
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
|
|
2044
2066
|
var _apiEndpoint$res;
|
|
2045
|
-
var contentTypeHeaders, json, valClientResult, responseResult;
|
|
2067
|
+
var contentTypeHeaders, json, valClientResult, message, responseResult;
|
|
2046
2068
|
return _regenerator().w(function (_context) {
|
|
2047
2069
|
while (1) switch (_context.n) {
|
|
2048
2070
|
case 0:
|
|
@@ -2092,12 +2114,13 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2092
2114
|
break;
|
|
2093
2115
|
}
|
|
2094
2116
|
console.error("Server responded with an error", json);
|
|
2117
|
+
message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
2095
2118
|
return _context.a(2, {
|
|
2096
2119
|
status: 500,
|
|
2097
|
-
json:
|
|
2120
|
+
json: {
|
|
2098
2121
|
type: "unknown",
|
|
2099
|
-
message:
|
|
2100
|
-
}
|
|
2122
|
+
message: message
|
|
2123
|
+
}
|
|
2101
2124
|
});
|
|
2102
2125
|
case 4:
|
|
2103
2126
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
|
@@ -2111,7 +2134,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2111
2134
|
message: "Response could not be validated. This could also be a result of mismatched Val versions.",
|
|
2112
2135
|
type: "client_side_validation_error",
|
|
2113
2136
|
details: {
|
|
2114
|
-
validationError:
|
|
2137
|
+
validationError: fromError(responseResult.error).toString(),
|
|
2115
2138
|
data: valClientResult
|
|
2116
2139
|
}
|
|
2117
2140
|
}
|
|
@@ -2284,7 +2307,7 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
2284
2307
|
root.page = {
|
|
2285
2308
|
fullPath: fullPath
|
|
2286
2309
|
};
|
|
2287
|
-
root.sourcePath = Internal.joinModuleFilePathAndModulePath(moduleFilePath, fullPath);
|
|
2310
|
+
root.sourcePath = Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
|
|
2288
2311
|
root.moduleFilePath = moduleFilePath;
|
|
2289
2312
|
return 0; // continue
|
|
2290
2313
|
}
|
|
@@ -2528,4 +2551,4 @@ function createRegExpFromPattern(pattern) {
|
|
|
2528
2551
|
}
|
|
2529
2552
|
}
|
|
2530
2553
|
|
|
2531
|
-
export { Api, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchId, PatchJSON, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, SharedValConfig, VAL_CONFIG_SESSION_STORAGE_KEY, VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_THEME_SESSION_STORAGE_KEY, ValCommit, ValDeployment, createRegExpFromPattern, createValClient, filterRoutesByPatterns, getNextAppRouterSitemapTree, getNextAppRouterSourceFolder, getPatternFromModuleFilePath, parseRoutePattern, remirrorToRichTextSource, richTextToRemirror, urlOf, validateRoutePatterns };
|
|
2554
|
+
export { Api, DEFAULT_ERROR_MESSAGE, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchId, PatchJSON, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, SharedValConfig, VAL_CONFIG_SESSION_STORAGE_KEY, VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_THEME_SESSION_STORAGE_KEY, ValCommit, ValDeployment, createRegExpFromPattern, createValClient, filterRoutesByPatterns, getErrorMessageFromUnknownJson, getNextAppRouterSitemapTree, getNextAppRouterSourceFolder, getPatternFromModuleFilePath, parseRoutePattern, remirrorToRichTextSource, richTextToRemirror, urlOf, validateRoutePatterns };
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valbuild/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Val shared types and utilities",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/valbuild/val.git"
|
|
9
9
|
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"typecheck": "tsc --noEmit",
|
|
12
|
-
"test": "jest"
|
|
13
|
-
},
|
|
14
10
|
"main": "dist/valbuild-shared.cjs.js",
|
|
15
11
|
"module": "dist/valbuild-shared.esm.js",
|
|
16
12
|
"exports": {
|
|
@@ -33,13 +29,20 @@
|
|
|
33
29
|
"exports": true
|
|
34
30
|
},
|
|
35
31
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"zod": "^
|
|
38
|
-
"
|
|
32
|
+
"zod": "^4.3.5",
|
|
33
|
+
"zod-validation-error": "^5.0.0",
|
|
34
|
+
"@valbuild/core": "0.93.0"
|
|
39
35
|
},
|
|
40
36
|
"files": [
|
|
41
37
|
"dist",
|
|
42
38
|
"internal/dist",
|
|
43
39
|
"internal/package.json"
|
|
44
|
-
]
|
|
45
|
-
|
|
40
|
+
],
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"test": "jest"
|
|
47
|
+
}
|
|
48
|
+
}
|