@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
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JSONValue as JSONValueT, PatchJSON as PatchJSONT, PatchBlock as PatchBlockT, ParentRef as ParentRefT } from "@valbuild/core/patch";
|
|
2
2
|
import type { PatchId as PatchIdT } from "@valbuild/core";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export declare const PatchJSON: z.ZodType<PatchJSONT>;
|
|
5
5
|
export type PatchJSON = PatchJSONT;
|
|
6
|
-
export declare const Patch: z.
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export declare const Patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
|
+
op: z.ZodLiteral<"add">;
|
|
8
|
+
path: z.ZodArray<z.ZodString>;
|
|
9
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
op: z.ZodLiteral<"remove">;
|
|
12
|
+
path: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
13
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
14
|
+
op: z.ZodLiteral<"replace">;
|
|
15
|
+
path: z.ZodArray<z.ZodString>;
|
|
16
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
op: z.ZodLiteral<"move">;
|
|
19
|
+
from: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
20
|
+
path: z.ZodArray<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
op: z.ZodLiteral<"copy">;
|
|
23
|
+
from: z.ZodArray<z.ZodString>;
|
|
24
|
+
path: z.ZodArray<z.ZodString>;
|
|
25
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
+
op: z.ZodLiteral<"test">;
|
|
27
|
+
path: z.ZodArray<z.ZodString>;
|
|
28
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
29
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
30
|
+
op: z.ZodLiteral<"file">;
|
|
31
|
+
path: z.ZodArray<z.ZodString>;
|
|
32
|
+
filePath: z.ZodString;
|
|
33
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
34
|
+
remote: z.ZodBoolean;
|
|
35
|
+
nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
37
|
+
}, z.core.$strict>], "op">>;
|
|
38
|
+
export type Patch = z.infer<typeof Patch>;
|
|
39
|
+
export declare const PatchId: z.ZodString & z.ZodType<PatchIdT, string, z.core.$ZodTypeInternals<PatchIdT, string>>;
|
|
9
40
|
type ParentRefInput = {
|
|
10
41
|
type: "head";
|
|
11
42
|
headBaseSha: string;
|
|
@@ -13,11 +44,42 @@ type ParentRefInput = {
|
|
|
13
44
|
type: "patch";
|
|
14
45
|
patchId: string;
|
|
15
46
|
};
|
|
16
|
-
export declare const ParentRef: z.ZodType<ParentRefT,
|
|
47
|
+
export declare const ParentRef: z.ZodType<ParentRefT, ParentRefInput>;
|
|
17
48
|
export type ParentRef = ParentRefT;
|
|
18
|
-
export declare const PatchBlock: z.
|
|
19
|
-
patch:
|
|
20
|
-
|
|
21
|
-
|
|
49
|
+
export declare const PatchBlock: z.ZodObject<{
|
|
50
|
+
patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
51
|
+
op: z.ZodLiteral<"add">;
|
|
52
|
+
path: z.ZodArray<z.ZodString>;
|
|
53
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
op: z.ZodLiteral<"remove">;
|
|
56
|
+
path: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
op: z.ZodLiteral<"replace">;
|
|
59
|
+
path: z.ZodArray<z.ZodString>;
|
|
60
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
61
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
+
op: z.ZodLiteral<"move">;
|
|
63
|
+
from: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
64
|
+
path: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
op: z.ZodLiteral<"copy">;
|
|
67
|
+
from: z.ZodArray<z.ZodString>;
|
|
68
|
+
path: z.ZodArray<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
op: z.ZodLiteral<"test">;
|
|
71
|
+
path: z.ZodArray<z.ZodString>;
|
|
72
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
op: z.ZodLiteral<"file">;
|
|
75
|
+
path: z.ZodArray<z.ZodString>;
|
|
76
|
+
filePath: z.ZodString;
|
|
77
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
78
|
+
remote: z.ZodBoolean;
|
|
79
|
+
nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
|
+
metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
81
|
+
}, z.core.$strict>], "op">>;
|
|
82
|
+
parentRef: z.ZodType<ParentRefT, ParentRefInput, z.core.$ZodTypeInternals<ParentRefT, ParentRefInput>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
22
84
|
export type PatchBlock = PatchBlockT;
|
|
23
85
|
export {};
|
|
@@ -7,21 +7,5 @@ export declare const ValCommit: z.ZodObject<{
|
|
|
7
7
|
creator: z.ZodString;
|
|
8
8
|
createdAt: z.ZodString;
|
|
9
9
|
commitMessage: z.ZodNullable<z.ZodString>;
|
|
10
|
-
},
|
|
11
|
-
commitSha: string;
|
|
12
|
-
clientCommitSha: string;
|
|
13
|
-
parentCommitSha: string;
|
|
14
|
-
branch: string;
|
|
15
|
-
creator: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
commitMessage: string | null;
|
|
18
|
-
}, {
|
|
19
|
-
commitSha: string;
|
|
20
|
-
clientCommitSha: string;
|
|
21
|
-
parentCommitSha: string;
|
|
22
|
-
branch: string;
|
|
23
|
-
creator: string;
|
|
24
|
-
createdAt: string;
|
|
25
|
-
commitMessage: string | null;
|
|
26
|
-
}>;
|
|
10
|
+
}, z.core.$strip>;
|
|
27
11
|
export type ValCommit = z.infer<typeof ValCommit>;
|
|
@@ -5,17 +5,5 @@ export declare const ValDeployment: z.ZodObject<{
|
|
|
5
5
|
commitSha: z.ZodString;
|
|
6
6
|
updatedAt: z.ZodString;
|
|
7
7
|
createdAt: z.ZodString;
|
|
8
|
-
},
|
|
9
|
-
commitSha: string;
|
|
10
|
-
createdAt: string;
|
|
11
|
-
deploymentId: string;
|
|
12
|
-
deploymentState: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
}, {
|
|
15
|
-
commitSha: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
deploymentId: string;
|
|
18
|
-
deploymentState: string;
|
|
19
|
-
updatedAt: string;
|
|
20
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
21
9
|
export type ValDeployment = z.infer<typeof ValDeployment>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
3
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
4
|
+
*
|
|
5
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
6
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
7
|
+
*/
|
|
8
|
+
export declare function base64DataUrlToUint8Array(dataUrl: string): Uint8Array;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
3
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
4
|
+
*
|
|
5
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
6
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
7
|
+
*/
|
|
8
|
+
function base64DataUrlToUint8Array(dataUrl) {
|
|
9
|
+
// Extract the base64 string from the data URL (everything after the comma)
|
|
10
|
+
var base64String = dataUrl.split(",")[1];
|
|
11
|
+
// Decode base64 to binary string
|
|
12
|
+
var binaryString = atob(base64String);
|
|
13
|
+
// Convert binary string to Uint8Array
|
|
14
|
+
var binaryData = new Uint8Array(binaryString.length);
|
|
15
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
16
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return binaryData;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { base64DataUrlToUint8Array as b };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
5
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
6
|
+
*
|
|
7
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
8
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
9
|
+
*/
|
|
10
|
+
function base64DataUrlToUint8Array(dataUrl) {
|
|
11
|
+
// Extract the base64 string from the data URL (everything after the comma)
|
|
12
|
+
var base64String = dataUrl.split(",")[1];
|
|
13
|
+
// Decode base64 to binary string
|
|
14
|
+
var binaryString = atob(base64String);
|
|
15
|
+
// Convert binary string to Uint8Array
|
|
16
|
+
var binaryData = new Uint8Array(binaryString.length);
|
|
17
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
18
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return binaryData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.base64DataUrlToUint8Array = base64DataUrlToUint8Array;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
5
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
6
|
+
*
|
|
7
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
8
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
9
|
+
*/
|
|
10
|
+
function base64DataUrlToUint8Array(dataUrl) {
|
|
11
|
+
// Extract the base64 string from the data URL (everything after the comma)
|
|
12
|
+
var base64String = dataUrl.split(",")[1];
|
|
13
|
+
// Decode base64 to binary string
|
|
14
|
+
var binaryString = atob(base64String);
|
|
15
|
+
// Convert binary string to Uint8Array
|
|
16
|
+
var binaryData = new Uint8Array(binaryString.length);
|
|
17
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
18
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return binaryData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.base64DataUrlToUint8Array = base64DataUrlToUint8Array;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var utils = require('./utils-d3d8b4b5.cjs.dev.js');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Val React **shared** types and utils.
|
|
7
9
|
*
|
|
@@ -12,4 +14,5 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
14
|
*/
|
|
13
15
|
var index = {};
|
|
14
16
|
|
|
17
|
+
exports.base64DataUrlToUint8Array = utils.base64DataUrlToUint8Array;
|
|
15
18
|
exports["default"] = index;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var utils = require('./utils-32bcaca2.cjs.prod.js');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Val React **shared** types and utils.
|
|
7
9
|
*
|
|
@@ -12,4 +14,5 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
14
|
*/
|
|
13
15
|
var index = {};
|
|
14
16
|
|
|
17
|
+
exports.base64DataUrlToUint8Array = utils.base64DataUrlToUint8Array;
|
|
15
18
|
exports["default"] = index;
|
|
@@ -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-d3d8b4b5.cjs.dev.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;
|