@valbuild/shared 0.91.4 → 0.92.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 +344 -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 +62 -38
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +62 -38
- package/internal/dist/valbuild-shared-internal.esm.js +62 -40
- 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"),
|
|
@@ -1803,9 +1806,9 @@ var Api = {
|
|
|
1803
1806
|
schemaSha: zod.z.string(),
|
|
1804
1807
|
sourcesSha: zod.z.string(),
|
|
1805
1808
|
modules: zod.z.record(ModuleFilePath, zod.z.object({
|
|
1806
|
-
render: zod.z.any(),
|
|
1809
|
+
render: zod.z.any().optional(),
|
|
1807
1810
|
// TODO: improve this type
|
|
1808
|
-
source: zod.z.any(),
|
|
1811
|
+
source: zod.z.any().optional(),
|
|
1809
1812
|
//.optional(), // TODO: Json zod type
|
|
1810
1813
|
patches: zod.z.object({
|
|
1811
1814
|
applied: zod.z.array(PatchId),
|
|
@@ -1891,7 +1894,7 @@ var Api = {
|
|
|
1891
1894
|
message: zod.z.string(),
|
|
1892
1895
|
details: zod.z.union([zod.z.object({
|
|
1893
1896
|
sourceFilePatchErrors: zod.z.record(ModuleFilePath, zod.z.array(GenericError)),
|
|
1894
|
-
binaryFilePatchErrors: zod.z.record(GenericError)
|
|
1897
|
+
binaryFilePatchErrors: zod.z.record(zod.z.string(), GenericError)
|
|
1895
1898
|
}), zod.z.array(GenericError)]).optional()
|
|
1896
1899
|
}), zod.z.object({
|
|
1897
1900
|
message: zod.z.string(),
|
|
@@ -1945,6 +1948,24 @@ var Api = {
|
|
|
1945
1948
|
* Do not change this without updating the ValRouter query parsing logic
|
|
1946
1949
|
* */
|
|
1947
1950
|
|
|
1951
|
+
function _typeof(o) {
|
|
1952
|
+
"@babel/helpers - typeof";
|
|
1953
|
+
|
|
1954
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
1955
|
+
return typeof o;
|
|
1956
|
+
} : function (o) {
|
|
1957
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1958
|
+
}, _typeof(o);
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
function getErrorMessageFromUnknownJson(json, fallback) {
|
|
1962
|
+
if (_typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
|
|
1963
|
+
return json.message;
|
|
1964
|
+
}
|
|
1965
|
+
return fallback;
|
|
1966
|
+
}
|
|
1967
|
+
var DEFAULT_ERROR_MESSAGE = "Unknown error with unknown message from server";
|
|
1968
|
+
|
|
1948
1969
|
var createValClient = function createValClient(host, config // We want to use this in the future
|
|
1949
1970
|
) {
|
|
1950
1971
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2029,7 +2050,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2029
2050
|
message: "There was an issue validating your data. This is most likely a Val bug.",
|
|
2030
2051
|
type: "client_side_validation_error",
|
|
2031
2052
|
details: {
|
|
2032
|
-
validationError: zodValidationError.
|
|
2053
|
+
validationError: zodValidationError.fromError(reqBodyResult.error).toString(),
|
|
2033
2054
|
data: anyReq.body
|
|
2034
2055
|
}
|
|
2035
2056
|
}
|
|
@@ -2046,7 +2067,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2046
2067
|
}).then(/*#__PURE__*/function () {
|
|
2047
2068
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
|
|
2048
2069
|
var _apiEndpoint$res;
|
|
2049
|
-
var contentTypeHeaders, json, valClientResult, responseResult;
|
|
2070
|
+
var contentTypeHeaders, json, valClientResult, message, responseResult;
|
|
2050
2071
|
return _regenerator().w(function (_context) {
|
|
2051
2072
|
while (1) switch (_context.n) {
|
|
2052
2073
|
case 0:
|
|
@@ -2096,12 +2117,13 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2096
2117
|
break;
|
|
2097
2118
|
}
|
|
2098
2119
|
console.error("Server responded with an error", json);
|
|
2120
|
+
message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
2099
2121
|
return _context.a(2, {
|
|
2100
2122
|
status: 500,
|
|
2101
|
-
json:
|
|
2123
|
+
json: {
|
|
2102
2124
|
type: "unknown",
|
|
2103
|
-
message:
|
|
2104
|
-
}
|
|
2125
|
+
message: message
|
|
2126
|
+
}
|
|
2105
2127
|
});
|
|
2106
2128
|
case 4:
|
|
2107
2129
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
|
@@ -2115,7 +2137,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2115
2137
|
message: "Response could not be validated. This could also be a result of mismatched Val versions.",
|
|
2116
2138
|
type: "client_side_validation_error",
|
|
2117
2139
|
details: {
|
|
2118
|
-
validationError: zodValidationError.
|
|
2140
|
+
validationError: zodValidationError.fromError(responseResult.error).toString(),
|
|
2119
2141
|
data: valClientResult
|
|
2120
2142
|
}
|
|
2121
2143
|
}
|
|
@@ -2288,7 +2310,7 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
2288
2310
|
root.page = {
|
|
2289
2311
|
fullPath: fullPath
|
|
2290
2312
|
};
|
|
2291
|
-
root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, fullPath);
|
|
2313
|
+
root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
|
|
2292
2314
|
root.moduleFilePath = moduleFilePath;
|
|
2293
2315
|
return 0; // continue
|
|
2294
2316
|
}
|
|
@@ -2533,6 +2555,7 @@ function createRegExpFromPattern(pattern) {
|
|
|
2533
2555
|
}
|
|
2534
2556
|
|
|
2535
2557
|
exports.Api = Api;
|
|
2558
|
+
exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
|
|
2536
2559
|
exports.ParentRef = ParentRef$1;
|
|
2537
2560
|
exports.Patch = Patch;
|
|
2538
2561
|
exports.PatchBlock = PatchBlock;
|
|
@@ -2560,6 +2583,7 @@ exports.ValDeployment = ValDeployment;
|
|
|
2560
2583
|
exports.createRegExpFromPattern = createRegExpFromPattern;
|
|
2561
2584
|
exports.createValClient = createValClient;
|
|
2562
2585
|
exports.filterRoutesByPatterns = filterRoutesByPatterns;
|
|
2586
|
+
exports.getErrorMessageFromUnknownJson = getErrorMessageFromUnknownJson;
|
|
2563
2587
|
exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
|
|
2564
2588
|
exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
|
|
2565
2589
|
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"),
|
|
@@ -1799,9 +1802,9 @@ var Api = {
|
|
|
1799
1802
|
schemaSha: z.string(),
|
|
1800
1803
|
sourcesSha: z.string(),
|
|
1801
1804
|
modules: z.record(ModuleFilePath, z.object({
|
|
1802
|
-
render: z.any(),
|
|
1805
|
+
render: z.any().optional(),
|
|
1803
1806
|
// TODO: improve this type
|
|
1804
|
-
source: z.any(),
|
|
1807
|
+
source: z.any().optional(),
|
|
1805
1808
|
//.optional(), // TODO: Json zod type
|
|
1806
1809
|
patches: z.object({
|
|
1807
1810
|
applied: z.array(PatchId),
|
|
@@ -1887,7 +1890,7 @@ var Api = {
|
|
|
1887
1890
|
message: z.string(),
|
|
1888
1891
|
details: z.union([z.object({
|
|
1889
1892
|
sourceFilePatchErrors: z.record(ModuleFilePath, z.array(GenericError)),
|
|
1890
|
-
binaryFilePatchErrors: z.record(GenericError)
|
|
1893
|
+
binaryFilePatchErrors: z.record(z.string(), GenericError)
|
|
1891
1894
|
}), z.array(GenericError)]).optional()
|
|
1892
1895
|
}), z.object({
|
|
1893
1896
|
message: z.string(),
|
|
@@ -1941,6 +1944,24 @@ var Api = {
|
|
|
1941
1944
|
* Do not change this without updating the ValRouter query parsing logic
|
|
1942
1945
|
* */
|
|
1943
1946
|
|
|
1947
|
+
function _typeof(o) {
|
|
1948
|
+
"@babel/helpers - typeof";
|
|
1949
|
+
|
|
1950
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
1951
|
+
return typeof o;
|
|
1952
|
+
} : function (o) {
|
|
1953
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1954
|
+
}, _typeof(o);
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function getErrorMessageFromUnknownJson(json, fallback) {
|
|
1958
|
+
if (_typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
|
|
1959
|
+
return json.message;
|
|
1960
|
+
}
|
|
1961
|
+
return fallback;
|
|
1962
|
+
}
|
|
1963
|
+
var DEFAULT_ERROR_MESSAGE = "Unknown error with unknown message from server";
|
|
1964
|
+
|
|
1944
1965
|
var createValClient = function createValClient(host, config // We want to use this in the future
|
|
1945
1966
|
) {
|
|
1946
1967
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2025,7 +2046,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2025
2046
|
message: "There was an issue validating your data. This is most likely a Val bug.",
|
|
2026
2047
|
type: "client_side_validation_error",
|
|
2027
2048
|
details: {
|
|
2028
|
-
validationError:
|
|
2049
|
+
validationError: fromError(reqBodyResult.error).toString(),
|
|
2029
2050
|
data: anyReq.body
|
|
2030
2051
|
}
|
|
2031
2052
|
}
|
|
@@ -2042,7 +2063,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2042
2063
|
}).then(/*#__PURE__*/function () {
|
|
2043
2064
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
|
|
2044
2065
|
var _apiEndpoint$res;
|
|
2045
|
-
var contentTypeHeaders, json, valClientResult, responseResult;
|
|
2066
|
+
var contentTypeHeaders, json, valClientResult, message, responseResult;
|
|
2046
2067
|
return _regenerator().w(function (_context) {
|
|
2047
2068
|
while (1) switch (_context.n) {
|
|
2048
2069
|
case 0:
|
|
@@ -2092,12 +2113,13 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2092
2113
|
break;
|
|
2093
2114
|
}
|
|
2094
2115
|
console.error("Server responded with an error", json);
|
|
2116
|
+
message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
2095
2117
|
return _context.a(2, {
|
|
2096
2118
|
status: 500,
|
|
2097
|
-
json:
|
|
2119
|
+
json: {
|
|
2098
2120
|
type: "unknown",
|
|
2099
|
-
message:
|
|
2100
|
-
}
|
|
2121
|
+
message: message
|
|
2122
|
+
}
|
|
2101
2123
|
});
|
|
2102
2124
|
case 4:
|
|
2103
2125
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
|
@@ -2111,7 +2133,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2111
2133
|
message: "Response could not be validated. This could also be a result of mismatched Val versions.",
|
|
2112
2134
|
type: "client_side_validation_error",
|
|
2113
2135
|
details: {
|
|
2114
|
-
validationError:
|
|
2136
|
+
validationError: fromError(responseResult.error).toString(),
|
|
2115
2137
|
data: valClientResult
|
|
2116
2138
|
}
|
|
2117
2139
|
}
|
|
@@ -2284,7 +2306,7 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
2284
2306
|
root.page = {
|
|
2285
2307
|
fullPath: fullPath
|
|
2286
2308
|
};
|
|
2287
|
-
root.sourcePath = Internal.joinModuleFilePathAndModulePath(moduleFilePath, fullPath);
|
|
2309
|
+
root.sourcePath = Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
|
|
2288
2310
|
root.moduleFilePath = moduleFilePath;
|
|
2289
2311
|
return 0; // continue
|
|
2290
2312
|
}
|
|
@@ -2528,4 +2550,4 @@ function createRegExpFromPattern(pattern) {
|
|
|
2528
2550
|
}
|
|
2529
2551
|
}
|
|
2530
2552
|
|
|
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 };
|
|
2553
|
+
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.92.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.92.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
|
+
}
|